Gui: ActiveObject: remove upon delete
Squashed with: Gui: MDIView: connection bug. Gui: MDIView: forgot disconnect.
This commit is contained in:
parent
c161ffaf44
commit
ae3916229d
|
@ -54,3 +54,18 @@ bool Gui::ActiveObjectList::hasObject(const char*name)const
|
||||||
{
|
{
|
||||||
return _ObjectMap.find(name) != _ObjectMap.end();
|
return _ObjectMap.find(name) != _ObjectMap.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActiveObjectList::objectDeleted(const ViewProviderDocumentObject& viewProviderIn)
|
||||||
|
{
|
||||||
|
App::DocumentObject* object = viewProviderIn.getObject();
|
||||||
|
//maybe boost::bimap or boost::multi_index
|
||||||
|
std::map<std::string, App::DocumentObject*>::iterator it;
|
||||||
|
for (it = _ObjectMap.begin(); it != _ObjectMap.end(); ++it)
|
||||||
|
{
|
||||||
|
if (it->second == object)
|
||||||
|
{
|
||||||
|
_ObjectMap.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace Gui
|
||||||
{
|
{
|
||||||
|
|
||||||
class Document;
|
class Document;
|
||||||
|
class ViewProviderDocumentObject;
|
||||||
|
|
||||||
/** List of active or special objects
|
/** List of active or special objects
|
||||||
* This class holds a list of objects with a special name.
|
* This class holds a list of objects with a special name.
|
||||||
|
@ -56,6 +57,7 @@ namespace Gui
|
||||||
}
|
}
|
||||||
void setObject(App::DocumentObject*, const char*, const Gui::HighlightMode& m = Gui::LightBlue);
|
void setObject(App::DocumentObject*, const char*, const Gui::HighlightMode& m = Gui::LightBlue);
|
||||||
bool hasObject(const char*)const;
|
bool hasObject(const char*)const;
|
||||||
|
void objectDeleted(const ViewProviderDocumentObject& viewProviderIn);
|
||||||
protected:
|
protected:
|
||||||
std::map<std::string, App::DocumentObject*> _ObjectMap;
|
std::map<std::string, App::DocumentObject*> _ObjectMap;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "PreCompiled.h"
|
#include "PreCompiled.h"
|
||||||
|
|
||||||
#ifndef _PreComp_
|
#ifndef _PreComp_
|
||||||
|
# include <boost/signals.hpp>
|
||||||
|
# include <boost/bind.hpp>
|
||||||
# include <qapplication.h>
|
# include <qapplication.h>
|
||||||
# include <qregexp.h>
|
# include <qregexp.h>
|
||||||
# include <QEvent>
|
# include <QEvent>
|
||||||
|
@ -38,6 +40,7 @@
|
||||||
#include "Document.h"
|
#include "Document.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include "ViewProviderDocumentObject.h"
|
||||||
|
|
||||||
using namespace Gui;
|
using namespace Gui;
|
||||||
|
|
||||||
|
@ -48,6 +51,13 @@ MDIView::MDIView(Gui::Document* pcDocument,QWidget* parent, Qt::WindowFlags wfla
|
||||||
: QMainWindow(parent, wflags), BaseView(pcDocument),currentMode(Child), wstate(Qt::WindowNoState)
|
: QMainWindow(parent, wflags), BaseView(pcDocument),currentMode(Child), wstate(Qt::WindowNoState)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
if (pcDocument)
|
||||||
|
{
|
||||||
|
connectDelObject = pcDocument->signalDeletedObject.connect
|
||||||
|
(boost::bind(&ActiveObjectList::objectDeleted, &ActiveObjects, _1));
|
||||||
|
assert(connectDelObject.connected());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MDIView::~MDIView()
|
MDIView::~MDIView()
|
||||||
|
@ -70,7 +80,8 @@ MDIView::~MDIView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (connectDelObject.connected())
|
||||||
|
connectDelObject.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDIView::deleteSelf()
|
void MDIView::deleteSelf()
|
||||||
|
|
|
@ -35,6 +35,7 @@ QT_END_NAMESPACE
|
||||||
namespace Gui
|
namespace Gui
|
||||||
{
|
{
|
||||||
class Document;
|
class Document;
|
||||||
|
class ViewProviderDocumentObject;
|
||||||
|
|
||||||
/** Base class of all windows belonging to a document.
|
/** Base class of all windows belonging to a document.
|
||||||
* There are two ways of belonging to a document:
|
* There are two ways of belonging to a document:
|
||||||
|
@ -147,8 +148,10 @@ protected:
|
||||||
private:
|
private:
|
||||||
ViewMode currentMode;
|
ViewMode currentMode;
|
||||||
Qt::WindowStates wstate;
|
Qt::WindowStates wstate;
|
||||||
// list of active objects of this view
|
// list of active objects of this view
|
||||||
ActiveObjectList ActiveObjects;
|
ActiveObjectList ActiveObjects;
|
||||||
|
typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
|
||||||
|
Connection connectDelObject; //remove active object upon delete.
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Gui
|
} // namespace Gui
|
||||||
|
|
Loading…
Reference in New Issue
Block a user