Skip to content

Commit

Permalink
disconnect boost signals when destroying tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 18, 2019
1 parent de53904 commit 42d7c7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Gui/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ TreeWidget::TreeWidget(QWidget* parent)
this, SLOT(onSearchObjects()));

// Setup connections
Application::Instance->signalNewDocument.connect(boost::bind(&TreeWidget::slotNewDocument, this, _1));
Application::Instance->signalDeleteDocument.connect(boost::bind(&TreeWidget::slotDeleteDocument, this, _1));
Application::Instance->signalRenameDocument.connect(boost::bind(&TreeWidget::slotRenameDocument, this, _1));
Application::Instance->signalActiveDocument.connect(boost::bind(&TreeWidget::slotActiveDocument, this, _1));
Application::Instance->signalRelabelDocument.connect(boost::bind(&TreeWidget::slotRelabelDocument, this, _1));
connectNewDocument = Application::Instance->signalNewDocument.connect(boost::bind(&TreeWidget::slotNewDocument, this, _1));
connectDelDocument = Application::Instance->signalDeleteDocument.connect(boost::bind(&TreeWidget::slotDeleteDocument, this, _1));
connectRenDocument = Application::Instance->signalRenameDocument.connect(boost::bind(&TreeWidget::slotRenameDocument, this, _1));
connectActDocument = Application::Instance->signalActiveDocument.connect(boost::bind(&TreeWidget::slotActiveDocument, this, _1));
connectRelDocument = Application::Instance->signalRelabelDocument.connect(boost::bind(&TreeWidget::slotRelabelDocument, this, _1));

QStringList labels;
labels << tr("Labels & Attributes");
Expand Down Expand Up @@ -163,6 +163,11 @@ TreeWidget::TreeWidget(QWidget* parent)

TreeWidget::~TreeWidget()
{
connectNewDocument.disconnect();
connectDelDocument.disconnect();
connectRenDocument.disconnect();
connectActDocument.disconnect();
connectRelDocument.disconnect();
}

void TreeWidget::contextMenuEvent (QContextMenuEvent * e)
Expand Down
7 changes: 7 additions & 0 deletions src/Gui/Tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ private Q_SLOTS:
static QPixmap* documentPixmap;
std::map<const Gui::Document*,DocumentItem*> DocumentMap;
bool fromOutside;

typedef boost::signals2::connection Connection;
Connection connectNewDocument;
Connection connectDelDocument;
Connection connectRenDocument;
Connection connectActDocument;
Connection connectRelDocument;
};

/** The link between the tree and a document.
Expand Down

0 comments on commit 42d7c7a

Please sign in to comment.