From 7a69c834d1de3f3f6885532a545b73225e20b4dc Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 15 Oct 2012 20:09:40 +0200 Subject: [PATCH] Add virtual method onSettingDocument() to do some delayed construction --- src/App/DocumentObject.cpp | 9 +++++---- src/App/DocumentObject.h | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index c0ac0f154..a48fac413 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -109,11 +109,11 @@ const char* DocumentObject::getStatusString(void) const const char *DocumentObject::getNameInDocument(void) const { - // Note: It can happen that we query the internal name of an object even if it is not - // part of a document (anymore). This is the case e.g. if we have a reference in Python - // to an object that has been removed from the document. In this case we should rather + // Note: It can happen that we query the internal name of an object even if it is not + // part of a document (anymore). This is the case e.g. if we have a reference in Python + // to an object that has been removed from the document. In this case we should rather // return 0. - //assert(pcNameInDocument); + //assert(pcNameInDocument); if (!pcNameInDocument) return 0; return pcNameInDocument->c_str(); } @@ -171,6 +171,7 @@ App::Document *DocumentObject::getDocument(void) const void DocumentObject::setDocument(App::Document* doc) { _pDoc=doc; + onSettingDocument(); } void DocumentObject::onBeforeChange(const Property* prop) diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 70a91ffe1..50d5b60b0 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -183,6 +183,8 @@ protected: virtual void onDocumentRestored() {} /// get called after duplicating an object virtual void onFinishDuplicating() {} + /// get called after setting the document + virtual void onSettingDocument() {} /// python object of this class and all descendend protected: // attributes