Phil Thompson wrote:
> Well, that turned out to be trivial. The attached modified script will work 
> with tonight's PyQt4 snapshot.

Here is a simple patch (just copy&paste from qmutex.sip) that adds the same
functionality to QReadLocker and QWriteLocker.

-Lukáš
diff -Naur QtCore.orig/qreadwritelock.sip QtCore/qreadwritelock.sip
--- QtCore.orig/qreadwritelock.sip	2006-10-19 03:36:00.000000000 +0200
+++ QtCore/qreadwritelock.sip	2006-10-19 12:09:48.000000000 +0200
@@ -55,6 +55,19 @@
     void relock() /ReleaseGIL/;
     QReadWriteLock *readWriteLock() const;
     QReadLocker(QReadWriteLock *areadWriteLock) /ReleaseGIL/;
+    SIP_PYOBJECT __enter__();
+%MethodCode
+        // Just return a reference to self.
+        sipRes = sipSelf;
+        Py_INCREF(sipRes);
+%End
+
+    void __exit__(SIP_PYOBJECT type, SIP_PYOBJECT value, SIP_PYOBJECT traceback);
+%MethodCode
+        // Unlock the mutex if an exception was raised.
+        if (a0 != Py_None || a1 != Py_None || a2 != Py_None)
+            sipCpp->unlock();
+%End
 
 private:
     QReadLocker(const QReadLocker &);
@@ -73,6 +86,19 @@
     void relock() /ReleaseGIL/;
     QReadWriteLock *readWriteLock() const;
     QWriteLocker(QReadWriteLock *areadWriteLock) /ReleaseGIL/;
+    SIP_PYOBJECT __enter__();
+%MethodCode
+        // Just return a reference to self.
+        sipRes = sipSelf;
+        Py_INCREF(sipRes);
+%End
+
+    void __exit__(SIP_PYOBJECT type, SIP_PYOBJECT value, SIP_PYOBJECT traceback);
+%MethodCode
+        // Unlock the mutex if an exception was raised.
+        if (a0 != Py_None || a1 != Py_None || a2 != Py_None)
+            sipCpp->unlock();
+%End
 
 private:
     QWriteLocker(const QWriteLocker &);
_______________________________________________
PyKDE mailing list    [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to