Skip to content

Commit

Permalink
Disconnect signals when the component is deleted (#9308)
Browse files Browse the repository at this point in the history
Fixes #9266
  • Loading branch information
adeas31 committed Aug 19, 2022
1 parent f1476ee commit 11f19cc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions OMEdit/OMEditLIB/Element/Element.cpp
Expand Up @@ -1644,6 +1644,14 @@ void Element::removeChildren()

void Element::emitAdded()
{
if (mpLibraryTreeItem) {
connect(mpLibraryTreeItem, SIGNAL(loadedForComponent()), SLOT(handleLoaded()));
connect(mpLibraryTreeItem, SIGNAL(unLoadedForComponent()), SLOT(handleUnloaded()));
connect(mpLibraryTreeItem, SIGNAL(coOrdinateSystemUpdatedForComponent()), SLOT(handleCoOrdinateSystemUpdated()));
connect(mpLibraryTreeItem, SIGNAL(shapeAddedForComponent()), SLOT(handleShapeAdded()));
connect(mpLibraryTreeItem, SIGNAL(componentAddedForComponent()), SLOT(handleElementAdded()));
connect(mpLibraryTreeItem, SIGNAL(nameChanged()), SLOT(handleNameChanged()));
}
if (mpGraphicsView->getViewType() == StringHandler::Icon) {
mpGraphicsView->getModelWidget()->getLibraryTreeItem()->handleIconUpdated();
}
Expand All @@ -1668,6 +1676,14 @@ void Element::emitChanged()

void Element::emitDeleted()
{
if (mpLibraryTreeItem) {
disconnect(mpLibraryTreeItem, SIGNAL(loadedForComponent()), this, SLOT(handleLoaded()));
disconnect(mpLibraryTreeItem, SIGNAL(unLoadedForComponent()), this, SLOT(handleUnloaded()));
disconnect(mpLibraryTreeItem, SIGNAL(coOrdinateSystemUpdatedForComponent()), this, SLOT(handleCoOrdinateSystemUpdated()));
disconnect(mpLibraryTreeItem, SIGNAL(shapeAddedForComponent()), this, SLOT(handleShapeAdded()));
disconnect(mpLibraryTreeItem, SIGNAL(componentAddedForComponent()), this, SLOT(handleElementAdded()));
disconnect(mpLibraryTreeItem, SIGNAL(nameChanged()), this, SLOT(handleNameChanged()));
}
if (mpGraphicsView->getViewType() == StringHandler::Icon) {
mpGraphicsView->getModelWidget()->getLibraryTreeItem()->handleIconUpdated();
}
Expand Down

0 comments on commit 11f19cc

Please sign in to comment.