saviopalmieri / ctypes-opencv

Automatically exported from code.google.com/p/ctypes-opencv
0 stars 0 forks source link

Suppress KeyError exception with mouse callback/trackbar on unknown window #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It's sort of a borderline case, but if a mouse callback is set or a
trackbar created for a non-existent window, it currently generates a
KeyError trying to update the _windows_callbacks cache.

The underlying highgui functions do not fail in such a case, silently
ignoring the request, so this patch mirrors that behavior.  I suppose
there's also a small realm of possibility of having Python code in the same
process as C code where the Python code wants to reference a window created
in the C code (and thus not known to highgui.py).

The other possibility would be to raise a Python-specific exception if it
got a window name it knew it didn't create.  But I think either this patch
or a specific exception would be better than a KeyError on an internal
object to the module, which isn't going to make sense to a user.

-- David

Original issue reported on code.google.com by db3l.em...@gmail.com on 12 Jan 2009 at 9:14

Attachments:

GoogleCodeExporter commented 8 years ago
Patched. Thanks.

Original comment by pmtri80@gmail.com on 14 Jan 2009 at 3:08