Skip to content

Commit 0791efd

Browse files
committed
Fix crash with insert module w/dynamic ports
1 parent 1ed940b commit 0791efd

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/Interface/Application/Connection.cc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -205,28 +205,35 @@ namespace SCIRun
205205
{
206206
deleteAction_ = addAction(deleteAction);
207207
addWidgetToExecutionDisableList(deleteAction_);
208-
insertAction_ = addAction(insertModuleAction);
209-
addWidgetToExecutionDisableList(insertAction_);
210-
211-
212-
auto insertable = new QMenu;
213-
fillInsertModuleMenu(insertable, Application::Instance().controller()->getAllAvailableModuleDescriptions(), conn->connectedPorts().first, conn);
214-
insertAction_->setMenu(insertable);
215-
208+
if (!eitherPortDynamic(conn->connectedPorts()))
209+
{
210+
insertAction_ = addAction(insertModuleAction);
211+
addWidgetToExecutionDisableList(insertAction_);
212+
auto insertable = new QMenu;
213+
fillInsertModuleMenu(insertable, Application::Instance().controller()->getAllAvailableModuleDescriptions(), conn->connectedPorts().first, conn);
214+
insertAction_->setMenu(insertable);
215+
}
216216
disableAction_ = addAction(disableEnableAction);
217217
addWidgetToExecutionDisableList(disableAction_);
218218
notesAction_ = addAction(editNotesAction);
219219
}
220220
~ConnectionMenu()
221221
{
222222
removeWidgetFromExecutionDisableList(deleteAction_);
223-
removeWidgetFromExecutionDisableList(insertAction_);
223+
if (insertAction_)
224+
removeWidgetFromExecutionDisableList(insertAction_);
224225
removeWidgetFromExecutionDisableList(disableAction_);
225226
}
226-
QAction* notesAction_;
227-
QAction* deleteAction_;
228-
QAction* disableAction_;
229-
QAction* insertAction_;
227+
QAction* notesAction_{ nullptr };
228+
QAction* deleteAction_{ nullptr };
229+
QAction* disableAction_{ nullptr };
230+
QAction* insertAction_{ nullptr };
231+
232+
private:
233+
bool eitherPortDynamic(const std::pair<PortWidget*, PortWidget*>& ports) const
234+
{
235+
return ports.first->isDynamic() || ports.second->isDynamic();
236+
}
230237
};
231238
}
232239
}

0 commit comments

Comments
 (0)