X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/afb810d936784286284f9fac9f522076ddd1e8c2..e961638138e832e7e9fc568d0aa7b32a2677bc3a:/wxPython/src/_extras.py diff --git a/wxPython/src/_extras.py b/wxPython/src/_extras.py index 6f61d91b81..866ab98cf7 100644 --- a/wxPython/src/_extras.py +++ b/wxPython/src/_extras.py @@ -551,19 +551,6 @@ def EVT_TOGGLEBUTTON(win, id, func): -# Help events -def EVT_HELP(win, id, func): - win.Connect(id, -1, wxEVT_HELP, func) - -def EVT_HELP_RANGE(win, id, id2, func): - win.Connect(id, id2, wxEVT_HELP, func) - -def EVT_DETAILED_HELP(win, id, func): - win.Connect(id, -1, wxEVT_DETAILED_HELP, func) - -def EVT_DETAILED_HELP_RANGE(win, id, id2, func): - win.Connect(id, id2, wxEVT_DETAILED_HELP, func) - def EVT_CONTEXT_MENU(win, func): win.Connect(-1, -1, wxEVT_CONTEXT_MENU, func) @@ -660,6 +647,26 @@ def wxPyTypeCast(obj, typeStr): return theObj +#---------------------------------------------------------------------------- + + +class _wxPyDeadObject: + """ + Instances of wx objects that are OOR capable will have their __class__ + changed to this class when the C++ object is deleted. This should help + prevent crashes due to referencing a bogus C++ pointer. + """ + def __repr__( self ): + if not hasattr(self, "_name"): + self._name = "[unknown]" + return 'wxPython wrapper for deleted %s object!!! Programming logic error' % self._name + + def __getattr__( self, *args ): + if not hasattr(self, "_name"): + self._name = "[unknown]" + raise ValueError, 'Attempt to access attribute of a deleted %s object' % self._name + + #---------------------------------------------------------------------- #---------------------------------------------------------------------- @@ -776,10 +783,10 @@ class wxPyWidgetTester(wxApp): self.frame.Show(true) #---------------------------------------------------------------------------- -# DO NOT hold any other references to this object. This is how we know when -# to cleanup system resources that wxWin is holding. When this module is -# unloaded, the refcount on __cleanMeUp goes to zero and it calls the -# wxApp_CleanUp function. +# DO NOT hold any other references to this object. This is how we +# know when to cleanup system resources that wxWin is holding. When +# the sys module is unloaded, the refcount on sys.__wxPythonCleanup +# goes to zero and it calls the wxApp_CleanUp function. class __wxPyCleanup: def __init__(self):