Skip to content

Commit 63601e6

Browse files
committed
Address review comments
1 parent 3390891 commit 63601e6

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

‎src/PythonQt.cpp‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,8 @@ bool PythonQt::addSignalHandler(QObject* obj, const char* signal, PyObject* modu
882882
PythonQtObjectPtr callable = lookupCallable(module, objectname);
883883
if (callable) {
884884
return _p->addSignalHandler(obj, signal, callable);
885-
} else {
886-
// callable not found
887885
}
886+
// callable not found
888887
return false;
889888
}
890889

@@ -898,9 +897,8 @@ bool PythonQt::removeSignalHandler(QObject* obj, const char* signal, PyObject* m
898897
PythonQtObjectPtr callable = lookupCallable(module, objectname);
899898
if (callable) {
900899
return _p->removeSignalHandler(obj, signal, callable);
901-
} else {
902-
// callable not found
903900
}
901+
// callable not found
904902
return false;
905903
}
906904

@@ -1977,21 +1975,20 @@ PythonQtClassInfo* PythonQtPrivate::lookupClassInfoAndCreateIfNotPresent(const c
19771975

19781976
bool PythonQtPrivate::addSignalHandler(QObject* sender, const char* signal, PyObject* callable)
19791977
{
1980-
// Note: It is assumed that the GIL is held when this is called
1981-
bool ok = false;
1978+
PYTHONQT_GIL_SCOPE
19821979
int sigId = PythonQtSignalReceiver::getSignalIndex(sender, signal);
19831980
if (sigId >= 0) {
19841981
// create PythonQtMethodInfo from signal
19851982
auto* receiver = new PythonQtSignalReceiver(sender, sigId, callable);
19861983
_signalReceivers.insert(SignalKey(sender, sigId), receiver);
1987-
ok = true;
1984+
return true;
19881985
}
1989-
return ok;
1986+
return false;
19901987
}
19911988

19921989
bool PythonQtPrivate::removeSignalHandler(QObject* sender, const char* signal, PyObject* callable)
19931990
{
1994-
// Note: It is assumed that the GIL is held when this is called
1991+
PYTHONQT_GIL_SCOPE
19951992
int foundCount = 0;
19961993
int sigId = PythonQtSignalReceiver::getSignalIndex(sender, signal);
19971994
if (sigId >= 0) {

‎src/PythonQt.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,13 +727,9 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject
727727
PythonQtClassInfo* lookupClassInfoAndCreateIfNotPresent(const char* typeName);
728728

729729
//! add a signal handler
730-
//!
731-
//! The GIL should be held when calling this
732730
bool addSignalHandler(QObject* sender, const char* signal, PyObject* callable);
733731

734732
//! remove a signal handler for given callable (or all callables on that signal if callable is NULL)
735-
//!
736-
//! The GIL should be held when calling this
737733
bool removeSignalHandler(QObject* sender, const char* signal, PyObject* callable = nullptr);
738734

739735
//! called when a signal receiver is deleted to remove it from the hash map

‎src/PythonQtSignalReceiver.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class PYTHONQT_EXPORT PythonQtSignalTarget
7171
//! call the python callable with the given arguments (as defined in methodInfo)
7272
void call(void** arguments) const;
7373

74-
//! check if it is this targets the same callable
74+
//! check if this targets the same callable
7575
bool isSame(PyObject* callable) const;
7676

7777
//! call the given callable with arguments described by PythonQtMethodInfo, returns a new reference as result value (or NULL)
@@ -109,7 +109,7 @@ class PythonQtSignalReceiver : public PythonQtSignalReceiverBase
109109
//! Returns the signal ID for which this receiver was created.
110110
int signalId() const { return _signalId; }
111111

112-
//! Check if this object targets the same callable given as argument.
112+
//! Check if this object targets the callable given as argument.
113113
bool isSameCallable(PyObject* callable) const;
114114

115115
//! Mark this object as already removed from the global list of signal receivers.

0 commit comments

Comments
 (0)