Skip to content

Commit

Permalink
Gui: fix crash on closing document
Browse files Browse the repository at this point in the history
Fixes #936
  • Loading branch information
realthunder committed Jan 18, 2024
1 parent 1c3b1f1 commit 09b8869
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Gui/ExpressionBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void ExpressionBinding::unbind()
{
expressionchanged.disconnect();
objectdeleted.disconnect();
docClosed.disconnect();
path = App::ObjectIdentifier();
}

Expand Down Expand Up @@ -146,6 +147,13 @@ void ExpressionBinding::bind(const App::ObjectIdentifier &_path)
expressionchanged = docObj->ExpressionEngine.expressionChanged.connect(boost::bind(&ExpressionBinding::expressionChange, this, bp::_1));
App::Document* doc = docObj->getDocument();
objectdeleted = doc->signalDeletedObject.connect(boost::bind(&ExpressionBinding::objectDeleted, this, bp::_1));
docClosed = App::GetApplication().signalDeleteDocument.connect(
[doc,this](const App::Document &docDelete) {
if (doc == &docDelete) {
unbind();
}
});

}
}

Expand Down
1 change: 1 addition & 0 deletions src/Gui/ExpressionBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class GuiExport ExpressionBinding
void objectDeleted(const App::DocumentObject&);
boost::signals2::scoped_connection expressionchanged;
boost::signals2::scoped_connection objectdeleted;
boost::signals2::scoped_connection docClosed;
bool m_autoApply;
};

Expand Down

0 comments on commit 09b8869

Please sign in to comment.