From 371f3baa87107038cbc67fd870edc88f0230206c Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 29 Oct 2012 20:11:30 +0100 Subject: [PATCH 1/2] Optimize loading of projects with many document objects --- src/App/Application.h | 4 +++- src/App/Document.cpp | 4 +++- src/Gui/Document.cpp | 32 +++++++++++++++++++++++++++----- src/Gui/Document.h | 7 ++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/App/Application.h b/src/App/Application.h index ca75c3fed..00099e0ee 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -112,8 +112,10 @@ public: boost::signal signalActiveDocument; /// signal on saving Document boost::signal signalSaveDocument; + /// signal on starting to restore Document + boost::signal signalStartRestoreDocument; /// signal on restoring Document - boost::signal signalRestoreDocument; + boost::signal signalFinishRestoreDocument; //@} diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 86b9ef79c..3ab7c2cae 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -999,6 +999,8 @@ void Document::restore (void) if (!reader.isValid()) throw Base::FileException("Error reading compression file",FileName.getValue()); + GetApplication().signalStartRestoreDocument(*this); + try { Document::Restore(reader); } @@ -1019,7 +1021,7 @@ void Document::restore (void) It->second->purgeTouched(); } - GetApplication().signalRestoreDocument(*this); + GetApplication().signalFinishRestoreDocument(*this); } bool Document::isSaved() const diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 1f629b2ab..7d91936bd 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -89,7 +89,8 @@ struct DocumentP Connection connectActObject; Connection connectSaveDocument; Connection connectRestDocument; - Connection connectLoadDocument; + Connection connectStartLoadDocument; + Connection connectFinishLoadDocument; }; } // namespace Gui @@ -127,8 +128,10 @@ Document::Document(App::Document* pcDocument,Application * app) (boost::bind(&Gui::Document::Save, this, _1)); d->connectRestDocument = pcDocument->signalRestoreDocument.connect (boost::bind(&Gui::Document::Restore, this, _1)); - d->connectLoadDocument = App::GetApplication().signalRestoreDocument.connect - (boost::bind(&Gui::Document::slotRestoredDocument, this, _1)); + d->connectStartLoadDocument = App::GetApplication().signalStartRestoreDocument.connect + (boost::bind(&Gui::Document::slotStartRestoreDocument, this, _1)); + d->connectFinishLoadDocument = App::GetApplication().signalFinishRestoreDocument.connect + (boost::bind(&Gui::Document::slotFinishRestoreDocument, this, _1)); // pointer to the python class // NOTE: As this Python object doesn't get returned to the interpreter we @@ -154,7 +157,8 @@ Document::~Document() d->connectActObject.disconnect(); d->connectSaveDocument.disconnect(); d->connectRestDocument.disconnect(); - d->connectLoadDocument.disconnect(); + d->connectStartLoadDocument.disconnect(); + d->connectFinishLoadDocument.disconnect(); // e.g. if document gets closed from within a Python command d->_isClosing = true; @@ -668,8 +672,26 @@ void Document::RestoreDocFile(Base::Reader &reader) setModified(false); } -void Document::slotRestoredDocument(const App::Document&) +void Document::slotStartRestoreDocument(const App::Document& doc) { + if (d->_pcDocument != &doc) + return; + // disable this singal while loading a document + d->connectActObject.block(); +} + +void Document::slotFinishRestoreDocument(const App::Document& doc) +{ + if (d->_pcDocument != &doc) + return; + d->connectActObject.unblock(); + App::DocumentObject* act = doc.getActiveObject(); + if (act) { + ViewProvider* viewProvider = getViewProvider(act); + if (viewProvider && viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { + signalActivatedObject(*(static_cast(viewProvider))); + } + } // some post-processing of view providers std::map::iterator it; for (it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) { diff --git a/src/Gui/Document.h b/src/Gui/Document.h index 9382c33bd..dc1acd875 100644 --- a/src/Gui/Document.h +++ b/src/Gui/Document.h @@ -68,7 +68,8 @@ protected: void slotChangedObject(const App::DocumentObject&, const App::Property&); void slotRenamedObject(const App::DocumentObject&); void slotActivatedObject(const App::DocumentObject&); - void slotRestoredDocument(const App::Document&); + void slotStartRestoreDocument(const App::Document&); + void slotFinishRestoreDocument(const App::Document&); //@} public: @@ -86,9 +87,9 @@ public: mutable boost::signal signalRenamedObject; /// signal on activated Object mutable boost::signal signalActivatedObject; - /// signal on goes in edti mode + /// signal on entering in edit mode mutable boost::signal signalInEdit; - /// signal on leave edit mode + /// signal on leaving edit mode mutable boost::signal signalResetEdit; //@} From 8d1ea0801a3b12ef3c0a2869e79f8892e45a55bb Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 29 Oct 2012 21:21:15 +0100 Subject: [PATCH 2/2] 0000858: Self-Test fails for testActivate v0.13.1539 --- src/Mod/Machining_Distortion/postprocess_gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Machining_Distortion/postprocess_gui.py b/src/Mod/Machining_Distortion/postprocess_gui.py index cf5d3ef19..79d1a4a2e 100755 --- a/src/Mod/Machining_Distortion/postprocess_gui.py +++ b/src/Mod/Machining_Distortion/postprocess_gui.py @@ -167,7 +167,7 @@ class MyForm(QtGui.QDialog,Ui_dialog): "set label \"" + z_axis_label + "\\nin [mm]\" at screen 0.03, screen 0.5 center rotate by 90\n"+ "set xtics in nomirror offset character 0,-0.5\n"+ "splot \"postprocessing_input.txt\" u " + str(offset_column) + ":" + str(rot_column) + ":" + str(abs_disp_column) + " with pm3d title \"\"\n" + - "exit" ) + "exit" )) gnu_plot_input_file.close() os.chdir(str(self.dirname))