1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 19:31:02 +01:00
Clementine-audio-player-Mac.../3rdparty/pythonqt/patches/signal-connected-signal.patch
2011-05-30 18:56:48 +00:00

84 lines
2.9 KiB
Diff

commit c06934993daab01ab831fa2478f1d11fb298afd5
Author: davidsansome <davidsansome@94c5599e-fc6c-11de-b061-8119ef04aefe>
Date: Mon May 30 14:53:59 2011 +0000
Remember any signals that are connected to Python objects and disconnect them when the script is unloaded so the references to those objects can be dropped
git-svn-id: https://clementine-player.googlecode.com/svn/trunk@3344 94c5599e-fc6c-11de-b061-8119ef04aefe
diff --git a/3rdparty/pythonqt/src/PythonQt.h b/3rdparty/pythonqt/src/PythonQt.h
index 050dadc..9a7c29f 100644
--- a/3rdparty/pythonqt/src/PythonQt.h
+++ b/3rdparty/pythonqt/src/PythonQt.h
@@ -453,6 +453,10 @@ signals:
//! emitted when help() is called on a PythonQt object and \c ExternalHelp is enabled
void pythonHelpRequest(const QByteArray& cppClassName);
+ //! emitted when a signal is connected to a Python object
+ void signalConnectedToPython(PythonQtSignalReceiver* receiver, int signal_id,
+ PyObject* callable);
+
private:
void initPythonQtModule(bool redirectStdOut, const QByteArray& pythonQtModuleName);
@@ -472,6 +476,7 @@ private:
PythonQtPrivate* _p;
+ friend class PythonQtSignalReceiver;
};
//! internal PythonQt details
diff --git a/3rdparty/pythonqt/src/PythonQtSignalReceiver.cpp b/3rdparty/pythonqt/src/PythonQtSignalReceiver.cpp
index d4074b1..7bb9dfc 100644
--- a/3rdparty/pythonqt/src/PythonQtSignalReceiver.cpp
+++ b/3rdparty/pythonqt/src/PythonQtSignalReceiver.cpp
@@ -170,22 +170,26 @@ bool PythonQtSignalReceiver::addSignalHandler(const char* signal, PyObject* call
_slotCount++;
flag = true;
+
+ PythonQt::self()->signalConnectedToPython(this, sigId, callable);
}
return flag;
}
bool PythonQtSignalReceiver::removeSignalHandler(const char* signal, PyObject* callable)
{
+ return removeSignalHandler(getSignalIndex(signal), callable);
+}
+
+bool PythonQtSignalReceiver::removeSignalHandler(int sigId, PyObject* callable)
+{
bool found = false;
- int sigId = getSignalIndex(signal);
- if (sigId>=0) {
- QMutableListIterator<PythonQtSignalTarget> i(_targets);
- while (i.hasNext()) {
- if (i.next().isSame(sigId, callable)) {
- i.remove();
- found = true;
- break;
- }
+ QMutableListIterator<PythonQtSignalTarget> i(_targets);
+ while (i.hasNext()) {
+ if (i.next().isSame(sigId, callable)) {
+ i.remove();
+ found = true;
+ break;
}
}
return found;
diff --git a/3rdparty/pythonqt/src/PythonQtSignalReceiver.h b/3rdparty/pythonqt/src/PythonQtSignalReceiver.h
index dfbcbc6..028b853 100644
--- a/3rdparty/pythonqt/src/PythonQtSignalReceiver.h
+++ b/3rdparty/pythonqt/src/PythonQtSignalReceiver.h
@@ -119,6 +119,7 @@ public:
//! remove a signal handler
bool removeSignalHandler(const char* signal, PyObject* callable);
+ bool removeSignalHandler(int sigId, PyObject* callable);
//! remove all signal handlers
void removeSignalHandlers();