From 2403af2e6c6331a4908fa7d7d9a6174e0759cbd4 Mon Sep 17 00:00:00 2001 From: jriegel Date: Thu, 23 Aug 2012 17:14:56 +0200 Subject: [PATCH] Fix bug in switching active Part/Assembly object when document with active one was closed --- src/Gui/TaskView/TaskWatcher.cpp | 7 +---- src/Gui/TaskView/TaskWatcher.h | 4 +-- src/Mod/Assembly/App/AppAssemblyPy.cpp | 33 ++++++++++++++--------- src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp | 31 ++++++++++++--------- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/Gui/TaskView/TaskWatcher.cpp b/src/Gui/TaskView/TaskWatcher.cpp index 4a7d14345..5e08c71d1 100644 --- a/src/Gui/TaskView/TaskWatcher.cpp +++ b/src/Gui/TaskView/TaskWatcher.cpp @@ -102,9 +102,6 @@ TaskWatcherCommands::TaskWatcherCommands(const char* Filter,const char* commands Content.push_back(tb); } -TaskWatcherCommands::~TaskWatcherCommands() -{ -} //==== implementer =========================================================================== @@ -128,9 +125,7 @@ TaskWatcherCommandsEmptyDoc::TaskWatcherCommandsEmptyDoc(const char* commands[], { } -TaskWatcherCommandsEmptyDoc::~TaskWatcherCommandsEmptyDoc() -{ -} + //==== implementer =========================================================================== diff --git a/src/Gui/TaskView/TaskWatcher.h b/src/Gui/TaskView/TaskWatcher.h index 613bec7ec..cd6e26df2 100644 --- a/src/Gui/TaskView/TaskWatcher.h +++ b/src/Gui/TaskView/TaskWatcher.h @@ -48,7 +48,7 @@ class GuiExport TaskWatcher : public QObject, public Gui::SelectionFilter public: TaskWatcher(const char* Filter); - ~TaskWatcher(); + virtual ~TaskWatcher(); std::vector &getWatcherContent(void); @@ -71,7 +71,6 @@ class GuiExport TaskWatcherCommands : public TaskWatcher public: TaskWatcherCommands(const char* Filter,const char* commands[], const char* name, const char* pixmap); - ~TaskWatcherCommands(); public: /// is called wenn the document or the Selection changes. @@ -88,7 +87,6 @@ class GuiExport TaskWatcherCommandsEmptyDoc : public TaskWatcherCommands public: TaskWatcherCommandsEmptyDoc(const char* commands[], const char* name, const char* pixmap); - ~TaskWatcherCommandsEmptyDoc(); public: /// is called wenn the document or the Selection changes. diff --git a/src/Mod/Assembly/App/AppAssemblyPy.cpp b/src/Mod/Assembly/App/AppAssemblyPy.cpp index 30ff96e61..133c8fdd5 100644 --- a/src/Mod/Assembly/App/AppAssemblyPy.cpp +++ b/src/Mod/Assembly/App/AppAssemblyPy.cpp @@ -38,34 +38,41 @@ // pointer to the active assembly object PartDesign::Body *ActivePartObject =0; -Gui::Document *ActiveGuiDoc =0; -Gui::ViewProviderDocumentObject *ActiveVp =0; +Gui::Document *ActiveGuiDoc =0; +App::Document *ActiveAppDoc =0; +Gui::ViewProviderDocumentObject *ActiveVp =0; static PyObject * setActivePart(PyObject *self, PyObject *args) { + if(ActivePartObject){ + // check if the document not already closed + std::vector docs = App::GetApplication().getDocuments(); + for(std::vector::const_iterator it=docs.begin();it!=docs.end();++it) + if(*it == ActiveAppDoc){ + ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,false); + break; + } + + ActivePartObject = 0; + ActiveGuiDoc =0; + ActiveAppDoc =0; + ActiveVp =0; + } + PyObject *object=0; if (PyArg_ParseTuple(args,"|O!",&(PartDesign::BodyPy::Type), &object)&& object) { PartDesign::Body* Item = static_cast(object)->getBodyPtr(); // Should be set! assert(Item); - // get the gui document of the Assembly Item - if(ActivePartObject){ - - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false); - ActivePartObject = 0; - - } ActivePartObject = Item; - ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument()); + ActiveAppDoc = Item->getDocument(); + ActiveGuiDoc = Gui::Application::Instance->getDocument(ActiveAppDoc); ActiveVp = dynamic_cast (ActiveGuiDoc->getViewProvider(Item)) ; ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,true); - }else{ - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,false); - ActivePartObject = 0; } Py_Return; diff --git a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp index 0409d69ae..22efa4eca 100644 --- a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp +++ b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp @@ -39,13 +39,29 @@ // pointer to the active assembly object Assembly::Item *ActiveAsmObject =0; Gui::Document *ActiveGuiDoc =0; +App::Document *ActiveAppDoc =0; Gui::ViewProviderDocumentObject *ActiveVp =0; /* module functions */ static PyObject * setActiveAssembly(PyObject *self, PyObject *args) -{ +{ + if(ActiveAsmObject){ + // check if the document not already closed + std::vector docs = App::GetApplication().getDocuments(); + for(std::vector::const_iterator it=docs.begin();it!=docs.end();++it) + if(*it == ActiveAppDoc){ + ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false); + break; + } + + ActiveAsmObject = 0; + ActiveGuiDoc =0; + ActiveAppDoc =0; + ActiveVp =0; + } + PyObject *object=0; if (PyArg_ParseTuple(args,"|O!",&(Assembly::ItemPy::Type), &object)&& object) { Assembly::Item* Item = static_cast(object)->getItemPtr(); @@ -53,20 +69,11 @@ static PyObject * setActiveAssembly(PyObject *self, PyObject *args) assert(Item); // get the gui document of the Assembly Item - if(ActiveAsmObject){ - - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false); - ActiveAsmObject = 0; - - } ActiveAsmObject = Item; - ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument()); + ActiveAppDoc = Item->getDocument(); + ActiveGuiDoc = Gui::Application::Instance->getDocument(ActiveAppDoc); ActiveVp = dynamic_cast (ActiveGuiDoc->getViewProvider(Item)) ; ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,true); - - }else{ - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false); - ActiveAsmObject = 0; } Py_Return;