From 4d9ddcfa66d5fec34d939731668b29410f1df004 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 3 Mar 2022 20:28:47 +0100 Subject: [PATCH] App: move member DocumentPythonObject to DocumentP --- src/App/Document.cpp | 10 ++++++---- src/App/Document.h | 5 ----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 12e9a1eb08..09a3e58497 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -164,6 +164,8 @@ struct DocumentP long lastObjectId; DocumentObject* activeObject; Transaction *activeUndoTransaction; + // pointer to the python class + Py::Object DocumentPythonObject; int iTransactionMode; bool rollback; bool undoing; ///< document in the middle of undo or redo @@ -1527,8 +1529,8 @@ Document::Document(const char *name) // So, we must increment only if the interpreter gets a reference. // Remark: We force the document Python object to own the DocumentPy instance, thus we don't // have to care about ref counting any more. - DocumentPythonObject = Py::Object(new DocumentPy(this), true); d = new DocumentP; + d->DocumentPythonObject = Py::Object(new DocumentPy(this), true); #ifdef FC_LOGUPDATECHAIN Console().Log("+App::Document: %p\n",this); @@ -1650,7 +1652,7 @@ Document::~Document() // But we must still invalidate the Python object because it doesn't need to be // destructed right now because the interpreter can own several references to it. Base::PyGILStateLocker lock; - Base::PyObjectBase* doc = (Base::PyObjectBase*)DocumentPythonObject.ptr(); + Base::PyObjectBase* doc = static_cast(d->DocumentPythonObject.ptr()); // Call before decrementing the reference counter, otherwise a heap error can occur doc->setInvalid(); @@ -4651,9 +4653,9 @@ int Document::countObjectsOfType(const Base::Type& typeId) const return ct; } -PyObject * Document::getPyObject(void) +PyObject * Document::getPyObject() { - return Py::new_reference_to(DocumentPythonObject); + return Py::new_reference_to(d->DocumentPythonObject); } std::vector Document::getRootObjects() const diff --git a/src/App/Document.h b/src/App/Document.h index 8602448766..27ba97dc57 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -23,9 +23,6 @@ #ifndef APP_DOCUMENT_H #define APP_DOCUMENT_H -#include -#include - #include "PropertyContainer.h" #include "PropertyLinks.h" #include "PropertyStandard.h" @@ -565,8 +562,6 @@ private: std::list mRedoTransactions; std::map mRedoMap; - // pointer to the python class - Py::Object DocumentPythonObject; struct DocumentP* d; std::string oldLabel;