108 lines
3.9 KiB
Diff
108 lines
3.9 KiB
Diff
diff -up system-config-printer-1.2.0/asyncipp.py.asyncipp-traceback system-config-printer-1.2.0/asyncipp.py
|
|
--- system-config-printer-1.2.0/asyncipp.py.asyncipp-traceback 2010-03-27 10:12:14.667366971 +0000
|
|
+++ system-config-printer-1.2.0/asyncipp.py 2010-03-27 10:13:04.081365616 +0000
|
|
@@ -59,6 +59,7 @@ class _IPPConnectionThread(threading.Thr
|
|
self._auth_handler = auth_handler
|
|
self._auth_queue = Queue.Queue (1)
|
|
self.user = None
|
|
+ self._destroyed = False
|
|
debugprint ("+%s" % self)
|
|
|
|
def __del__ (self):
|
|
@@ -157,6 +158,7 @@ class _IPPConnectionThread(threading.Thr
|
|
self._queue.task_done ()
|
|
|
|
debugprint ("Thread exiting")
|
|
+ self._destroyed = True
|
|
del self._conn # already destroyed
|
|
del self._reply_handler
|
|
del self._error_handler
|
|
@@ -188,21 +190,23 @@ class _IPPConnectionThread(threading.Thr
|
|
return password
|
|
|
|
def _reply (self, result):
|
|
- def send_reply (result):
|
|
- self._reply_handler (self._conn, result)
|
|
+ def send_reply (handler, result):
|
|
+ if not self._destroyed:
|
|
+ handler (self._conn, result)
|
|
return False
|
|
|
|
- if self._reply_handler:
|
|
- gobject.idle_add (send_reply, result)
|
|
+ if not self._destroyed and self._reply_handler:
|
|
+ gobject.idle_add (send_reply, self._reply_handler, result)
|
|
|
|
def _error (self, exc):
|
|
- def send_error (exc):
|
|
- self._error_handler (self._conn, exc)
|
|
+ def send_error (handler, exc):
|
|
+ if not self._destroyed:
|
|
+ handler (self._conn, exc)
|
|
return False
|
|
|
|
- if self._error_handler:
|
|
+ if not self._destroyed and self._error_handler:
|
|
debugprint ("Add %s to idle" % self._error_handler)
|
|
- gobject.idle_add (send_error, exc)
|
|
+ gobject.idle_add (send_error, self._error_handler, exc)
|
|
|
|
###
|
|
### This is the user-visible class. Although it does not inherit from
|
|
diff -up system-config-printer-1.2.0/asyncpk1.py.asyncipp-traceback system-config-printer-1.2.0/asyncpk1.py
|
|
--- system-config-printer-1.2.0/asyncpk1.py.asyncipp-traceback 2010-03-27 10:12:14.702364469 +0000
|
|
+++ system-config-printer-1.2.0/asyncpk1.py 2010-03-27 10:13:06.407243790 +0000
|
|
@@ -64,6 +64,7 @@ class _PK1AsyncMethodCall:
|
|
self._fallback_fn = fallback_fn
|
|
self._fallback_args = args
|
|
self._fallback_kwds = kwds
|
|
+ self._destroyed = False
|
|
debugprint ("+_PK1AsyncMethodCall: %s" % self)
|
|
|
|
def __del__ (self):
|
|
@@ -85,6 +86,7 @@ class _PK1AsyncMethodCall:
|
|
|
|
def _destroy (self):
|
|
debugprint ("DESTROY: %s" % self)
|
|
+ self._destroyed = True
|
|
del self._bus
|
|
del self._conn
|
|
del self._pk_method_name
|
|
@@ -97,6 +99,9 @@ class _PK1AsyncMethodCall:
|
|
del self._fallback_kwds
|
|
|
|
def _pk_reply_handler (self, error, *args):
|
|
+ if self._destroyed:
|
|
+ return
|
|
+
|
|
if str (error) == '':
|
|
self._client_reply_handler (self._conn, self._unpack_fn (*args))
|
|
self._destroy ()
|
|
@@ -106,6 +111,9 @@ class _PK1AsyncMethodCall:
|
|
self.call_fallback_fn ()
|
|
|
|
def _pk_error_handler (self, exc):
|
|
+ if self._destroyed:
|
|
+ return
|
|
+
|
|
if exc.get_dbus_name () == CUPS_PK_NEED_AUTH:
|
|
exc = cups.IPPError (cups.IPP_NOT_AUTHORIZED, 'pkcancel')
|
|
self._client_error_handler (self._conn, exc)
|
|
@@ -123,10 +131,16 @@ class _PK1AsyncMethodCall:
|
|
self._fallback_fn (*self._fallback_args, **self._fallback_kwds)
|
|
|
|
def _ipp_reply_handler (self, conn, *args):
|
|
+ if self._destroyed:
|
|
+ return
|
|
+
|
|
self._client_reply_handler (self._conn, *args)
|
|
self._destroy ()
|
|
|
|
def _ipp_error_handler (self, conn, *args):
|
|
+ if self._destroyed:
|
|
+ return
|
|
+
|
|
self._client_error_handler (self._conn, *args)
|
|
self._destroy ()
|
|
|