Re: [ctypes-users] ctypes on Vista
Brought to you by:
theller
From: Matt H. (matherbe) <mat...@ci...> - 2008-03-03 21:07:58
|
> -----Original Message----- > From: Tibor Horvath [mailto:ti...@cs...] > Sent: Monday, March 03, 2008 3:31 PM > To: Matt Herbert (matherbe) > Cc: cty...@li... > Subject: Re: [ctypes-users] ctypes on Vista > > Matt Herbert (matherbe) wrote: > > def registerCallback(self): > > > > callback = ctypes.CFUNCTYPE(None, \ > > ctypes.POINTER(WLAN_NOTIFICATION_DATA), \ > > ctypes.POINTER(ctypes.c_void_p) ) > > > > wlanapi.WlanRegisterNotification(\ > > self.handle, > > WLAN_NOTIFICATION_SOURCE_ALL, > > False, > > callback(self.notifyCallback), > > I think the line above is the problem. You create a ctypes function > object that has no references in your code and therefore is > subject to > garbage collection. > > > > > Thanks > > -Matt > > Tibor > That did it. I changed the code, so that before the call to WlanRegisterNotification(), I added: self.theCallback = callback(self.notifyCallback) Then I passed "self.theCallback" into the register function, and now everything is working perfectly, no more crashes! Thanks a lot! -Matt |