Skip to content

Commit

Permalink
[dataflow][qtgui] fix crash when ending graph edition session
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Feb 10, 2023
1 parent b290126 commit 4b48685
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Dataflow/QtGui/GraphEditor/GraphEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ namespace GraphEditor {
using namespace Ra::Dataflow::Core;

GraphEditorWindow::~GraphEditorWindow() {
// Prevent graph destruction if the editor is used to work with active graphs.
auto graphProtection = m_graph->getNodesAndLinksProtection();
if ( !m_ownGraph ) { m_graph->setNodesAndLinksProtection( true ); }
delete m_graphEdit;
if ( !m_ownGraph ) { m_graph->setNodesAndLinksProtection( graphProtection ); }
if ( m_graph ) {
// Prevent graph destruction if the editor is used to work with active graphs.
auto graphProtection = m_graph->getNodesAndLinksProtection();
if ( !m_ownGraph ) { m_graph->setNodesAndLinksProtection( true ); }
delete m_graphEdit;
if ( !m_ownGraph ) { m_graph->setNodesAndLinksProtection( graphProtection ); }
else {
delete m_graph;
}
}
else {
delete m_graph;
delete m_graphEdit;
}
}

Expand Down Expand Up @@ -101,6 +106,7 @@ bool GraphEditorWindow::saveAs() {
QFileDialog dialog( this );
dialog.setWindowModality( Qt::WindowModal );
dialog.setAcceptMode( QFileDialog::AcceptSave );
dialog.setDefaultSuffix( "json" );
if ( dialog.exec() != QDialog::Accepted ) return false;
return saveFile( dialog.selectedFiles().first() );
}
Expand Down

0 comments on commit 4b48685

Please sign in to comment.