Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: added sanity checks for compatibility with pyqtgraph #81

Open
wants to merge 1 commit into
base: patched-9
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/PythonQtClassInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ PythonQtSlotInfo* PythonQtClassInfo::recursiveFindDecoratorSlotsFromDecoratorPro
{
inputInfo = findDecoratorSlotsFromDecoratorProvider(memberName, inputInfo, found, memberCache, upcastingOffset);
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
inputInfo = info._parent->recursiveFindDecoratorSlotsFromDecoratorProvider(memberName, inputInfo, found, memberCache, upcastingOffset+info._upcastingOffset);
if (this != info._parent)
inputInfo = info._parent->recursiveFindDecoratorSlotsFromDecoratorProvider(memberName, inputInfo, found, memberCache, upcastingOffset+info._upcastingOffset);
}
return inputInfo;
}
Expand Down Expand Up @@ -385,14 +386,16 @@ void PythonQtClassInfo::recursiveCollectDecoratorObjects(QList<QObject*>& decora
decoratorObjects.append(deco);
}
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
info._parent->recursiveCollectDecoratorObjects(decoratorObjects);
if (this != info._parent)
info._parent->recursiveCollectDecoratorObjects(decoratorObjects);
}
}

void PythonQtClassInfo::recursiveCollectClassInfos(QList<PythonQtClassInfo*>& classInfoObjects) {
classInfoObjects.append(this);
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
info._parent->recursiveCollectClassInfos(classInfoObjects);
if (this != info._parent)
info._parent->recursiveCollectClassInfos(classInfoObjects);
}
}

Expand Down Expand Up @@ -584,7 +587,7 @@ bool PythonQtClassInfo::inherits(const char* name)
return true;
}
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
if (info._parent->inherits(name)) {
if (info._parent != this && info._parent->inherits(name)) {
return true;
}
}
Expand All @@ -597,7 +600,7 @@ bool PythonQtClassInfo::inherits(PythonQtClassInfo* classInfo)
return true;
}
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
if (info._parent->inherits(classInfo)) {
if (info._parent != this && info._parent->inherits(classInfo)) {
return true;
}
}
Expand Down Expand Up @@ -761,8 +764,10 @@ void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, const char** res
}
}
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
void* resultPtr = NULL;
if (!info._parent->isQObject()) {
void* resultPtr = info._parent->recursiveCastDownIfPossible((char*)ptr + info._upcastingOffset, resultClassName);
if (this != info._parent)
resultPtr = info._parent->recursiveCastDownIfPossible((char*)ptr + info._upcastingOffset, resultClassName);
if (resultPtr) {
return resultPtr;
}
Expand Down Expand Up @@ -870,7 +875,8 @@ void PythonQtClassInfo::createEnumWrappers(const QObject* decoratorProvider)
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
// trigger decorator() instead of createEnumWrappers(),
// which will then call createEnumWrappers().
info._parent->decorator();
if (info._parent != this)
info._parent->decorator();
}
}
}
Expand All @@ -889,7 +895,9 @@ PyObject* PythonQtClassInfo::findEnumWrapper(const char* name) {
}
}
Q_FOREACH(const ParentClassInfo& info, _parentClasses) {
PyObject* p = info._parent->findEnumWrapper(name);
PyObject* p = NULL;
if (info._parent != this)
p = info._parent->findEnumWrapper(name);
if (p) return p;
}
return NULL;
Expand Down Expand Up @@ -1004,6 +1012,9 @@ void PythonQtClassInfo::updateRefCountingCBs()
if (!_parentClasses.isEmpty()) {
// we only search in single inheritance, using the first parent class
PythonQtClassInfo* parent = _parentClasses.at(0)._parent;
if (parent == this)
_searchRefCountCB = false;
return;
parent->updateRefCountingCBs();
// propagate to ourself
_refCallback = parent->_refCallback;
Expand Down