|
41 | 41 | #include <QByteArray> |
42 | 42 | #include <QList> |
43 | 43 |
|
44 | | -class PythonQtSlotInfo; |
45 | | -class PythonQtClassInfo; |
| 44 | +#include <PythonQtMethodInfo.h> |
46 | 45 |
|
47 | 46 | struct PythonQtDynamicClassInfo |
48 | 47 | { |
49 | | - PythonQtDynamicClassInfo() { _dynamicMetaObject = nullptr; _classInfo = nullptr; } |
50 | | - ~PythonQtDynamicClassInfo(); |
51 | | - |
52 | | - const QMetaObject* _dynamicMetaObject; |
53 | | - PythonQtClassInfo* _classInfo; |
| 48 | + const QMetaObject* _dynamicMetaObject {}; |
| 49 | + QScopedPointer<PythonQtClassInfo> _classInfo; |
54 | 50 | }; |
55 | 51 |
|
56 | 52 | struct PythonQtMemberInfo { |
57 | 53 | enum Type { |
58 | 54 | Invalid, Slot, Signal, EnumValue, EnumWrapper, Property, NestedClass, NotFound |
59 | 55 | }; |
60 | 56 |
|
61 | | - PythonQtMemberInfo():_type(Invalid),_slot(nullptr),_pythonType(nullptr),_enumValue(nullptr) { } |
| 57 | + PythonQtMemberInfo() = default; |
62 | 58 |
|
63 | | - PythonQtMemberInfo(PythonQtSlotInfo* info); |
| 59 | + explicit PythonQtMemberInfo(PythonQtSlotInfo* info) |
| 60 | + : _type(info->metaMethod()->methodType() == QMetaMethod::Signal? Signal : Slot) |
| 61 | + , _slot(info) |
| 62 | + {} |
64 | 63 |
|
65 | | - PythonQtMemberInfo(const PythonQtObjectPtr& enumValue); |
| 64 | + explicit PythonQtMemberInfo(PyObject* enumValue) |
| 65 | + : _type (EnumValue), _enumValue(enumValue) |
| 66 | + {} |
66 | 67 |
|
67 | | - PythonQtMemberInfo(const QMetaProperty& prop); |
| 68 | + explicit PythonQtMemberInfo(const QMetaProperty& prop) |
| 69 | + : _type (Property), _property(prop) |
| 70 | + {} |
68 | 71 |
|
69 | | - Type _type; |
| 72 | + Type _type { Invalid }; |
70 | 73 |
|
71 | 74 | // TODO: this could be a union... |
72 | | - PythonQtSlotInfo* _slot; |
73 | | - PyObject* _pythonType; |
74 | | - PythonQtObjectPtr _enumValue; |
| 75 | + PythonQtSlotInfo* _slot {}; |
| 76 | + PyObject* _pythonType {}; |
| 77 | + PyObject* _enumValue {}; |
75 | 78 | QMetaProperty _property; |
76 | 79 | }; |
77 | 80 |
|
@@ -177,10 +180,10 @@ class PYTHONQT_EXPORT PythonQtClassInfo { |
177 | 180 | void addParentClass(const ParentClassInfo& info) { _parentClasses.append(info); } |
178 | 181 |
|
179 | 182 | //! set the associated PythonQtClassWrapper (which handles instance creation of this type) |
180 | | - void setPythonQtClassWrapper(PyObject* obj) { _pythonQtClassWrapper = obj; } |
| 183 | + void setPythonQtClassWrapper(PyObject* obj) { _pythonQtClassWrapper.setNewRef(obj); } |
181 | 184 |
|
182 | 185 | //! get the associated PythonQtClassWrapper (which handles instance creation of this type) |
183 | | - PyObject* pythonQtClassWrapper() { return _pythonQtClassWrapper; } |
| 186 | + PyObject* pythonQtClassWrapper() { return _pythonQtClassWrapper.object(); } |
184 | 187 |
|
185 | 188 | //! set the shell set instance wrapper cb |
186 | 189 | void setShellSetInstanceWrapperCB(PythonQtShellSetInstanceWrapperCB* cb) { |
@@ -244,6 +247,9 @@ class PYTHONQT_EXPORT PythonQtClassInfo { |
244 | 247 | //! Add a wrapper that contains global enums |
245 | 248 | static void addGlobalNamespaceWrapper(PythonQtClassInfo* namespaceWrapper); |
246 | 249 |
|
| 250 | + //! Clear all statically allocated caches and wrappers |
| 251 | + static void clearInteralStaticData(); |
| 252 | + |
247 | 253 | private: |
248 | 254 | void updateRefCountingCBs(); |
249 | 255 |
|
@@ -294,7 +300,7 @@ class PYTHONQT_EXPORT PythonQtClassInfo { |
294 | 300 | QObject* _decoratorProvider; |
295 | 301 | PythonQtQObjectCreatorFunctionCB* _decoratorProviderCB; |
296 | 302 |
|
297 | | - PyObject* _pythonQtClassWrapper; |
| 303 | + PythonQtObjectPtr _pythonQtClassWrapper; |
298 | 304 |
|
299 | 305 | PythonQtShellSetInstanceWrapperCB* _shellSetInstanceWrapperCB; |
300 | 306 |
|
|
0 commit comments