Skip to content

Commit 5655a89

Browse files
committed
Fix crashes; subnets always on top
1 parent 6182a42 commit 5655a89

File tree

12 files changed

+701
-41
lines changed

12 files changed

+701
-41
lines changed

src/ExampleNets/regression/subnet3.srn5

Lines changed: 671 additions & 0 deletions
Large diffs are not rendered by default.

src/Interface/Application/ModuleWidget.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,14 @@ void ModuleWidget::resizeBasedOnModuleName(ModuleWidgetDisplayBase* display, int
458458
{
459459
auto frame = this;
460460
int pixelWidth = display->getTitleWidth();
461-
//qDebug() << moduleId_.c_str();
462-
//qDebug() << "\tPixelwidth = " << pixelWidth;
463461
int extraWidth = pixelWidth - ModuleWidgetDisplayBase::moduleWidthThreshold;
464-
//qDebug() << "\textraWidth = " << extraWidth;
465462
if (extraWidth > ModuleWidgetDisplayBase::extraWidthThreshold)
466463
{
467-
//qDebug() << "\tGROWING MODULE Current width: " << frame->width();
468464
frame->resize(frame->width() + extraWidth + ModuleWidgetDisplayBase::extraModuleWidth, frame->height());
469-
//qDebug() << "\tNew width: " << frame->width();
470465
}
471466
else
472467
{
473-
//qDebug() << "\tSHRINKING MODULE Current width: " << frame->width();
474468
frame->resize(frame->width() - ModuleWidgetDisplayBase::smushFactor, frame->height());
475-
//qDebug() << "\tNew width: " << frame->width();
476469
}
477470
}
478471

@@ -571,7 +564,6 @@ void ModuleWidget::fillReplaceWithMenu()
571564

572565
void ModuleWidget::menuFunction()
573566
{
574-
qDebug() << "ModuleWidget::menuFunction";
575567
// fullWidgetDisplay_->getModuleActionButton()->setMenu(nullptr);
576568
// actionsMenu_.reset();
577569
}
@@ -744,7 +736,6 @@ void ModuleWidget::addOutputPortsToWidget(int index)
744736
}
745737
else
746738
{
747-
qDebug() << "OOPS NO OUTPUT PORTS";
748739
}
749740
}
750741

@@ -811,7 +802,6 @@ void ModuleWidget::addInputPortsToWidget(int index)
811802
}
812803
else
813804
{
814-
qDebug() << "OOPS NO INPUT PORTS";
815805
}
816806
}
817807

src/Interface/Application/ModuleWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,11 @@ class SubnetWidget : public ModuleWidget
312312
SubnetWidget(NetworkEditor* ed, const QString& name, Dataflow::Networks::ModuleHandle theModule, boost::shared_ptr<DialogErrorControl> dialogErrorControl, QWidget* parent = nullptr);
313313
~SubnetWidget();
314314
void postLoadAction() override;
315+
void deleteSubnetImmediately() { deleteSubnetImmediately_ = true; }
315316
private:
316317
NetworkEditor* editor_;
317318
QString name_;
319+
bool deleteSubnetImmediately_{ false };
318320
};
319321

320322
class SubnetPortsBridgeWidget : public QWidget

src/Interface/Application/NetworkEditor.cc

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,10 @@ ModuleProxyWidget* NetworkEditor::setupModuleWidget(ModuleWidget* module)
404404

405405
if (highResolutionExpandFactor_ > 1)
406406
{
407-
//qDebug() << "module widget expand factor:" << highResolutionExpandFactor_;
408-
//qDebug() << proxy->size();
409407
module->setFixedHeight(proxy->size().height() * highResolutionExpandFactor_);
410408
proxy->setMaximumHeight(proxy->size().height() * highResolutionExpandFactor_);
411409
module->setFixedWidth(proxy->size().width() * std::max(highResolutionExpandFactor_*0.9, 1.0));
412410
proxy->setMaximumWidth(proxy->size().width() * std::max(highResolutionExpandFactor_*0.9, 1.0));
413-
//qDebug() << proxy->size();
414411
}
415412

416413
scene_->addItem(proxy);
@@ -543,7 +540,13 @@ void NetworkEditor::del()
543540
if (!isActiveWindow())
544541
return;
545542

546-
auto items = scene_->selectedItems();
543+
deleteImpl(scene_->selectedItems());
544+
updateViewport();
545+
Q_EMIT modified();
546+
}
547+
548+
void NetworkEditor::deleteImpl(QList<QGraphicsItem*> items)
549+
{
547550
QMutableListIterator<QGraphicsItem*> i(items);
548551
while (i.hasNext())
549552
{
@@ -556,8 +559,6 @@ void NetworkEditor::del()
556559
}
557560
}
558561
qDeleteAll(items);
559-
updateViewport();
560-
Q_EMIT modified();
561562
}
562563

563564
void NetworkEditor::cut()
@@ -832,7 +833,6 @@ class NetworkSearchEngine
832833
}
833834
else
834835
{
835-
//qDebug() << "something else";
836836
}
837837
results.insert(results.end(), subresults.begin(), subresults.end());
838838
}
@@ -1325,7 +1325,16 @@ void NetworkEditor::clear()
13251325
{
13261326
tagLabelOverrides_.clear();
13271327
ModuleWidget::NetworkClearingScope clearing;
1328-
//auto portSwitch = createDynamicPortDisabler();
1328+
1329+
QList<QGraphicsItem*> deleteTheseFirst;
1330+
Q_FOREACH(QGraphicsItem* item, scene_->items())
1331+
{
1332+
if (auto s = dynamic_cast<SubnetWidget*>(getModule(item)))
1333+
{
1334+
deleteTheseFirst.append(item);
1335+
}
1336+
}
1337+
deleteImpl(deleteTheseFirst);
13291338
scene_->clear();
13301339
//TODO: this (unwritten) method does not need to be called here. the dtors of all the module widgets get called when the scene_ is cleared, which triggered removal from the underlying network.
13311340
// we'll need a similar hook when programming the scripting interface (moduleWidgets<->modules).
@@ -1642,7 +1651,6 @@ void NetworkEditor::zoomBestFit()
16421651
auto oldRect = sceneRect();
16431652
setSceneRect(QRectF());
16441653
fitInView(sceneRect(), Qt::KeepAspectRatio);
1645-
//qDebug() << "old rect: " << oldRect << "new rect:" << sceneRect();
16461654
currentScale_ *= sceneRect().x() / oldRect.x();
16471655
//scale(1.0 / currentScale_, 1.0 / currentScale_);
16481656
//currentScale_ = 1;

src/Interface/Application/NetworkEditor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ namespace Gui {
262262

263263
NetworkEditor* parentNetwork() { return parentNetwork_; }
264264
size_t childCount() const { return childrenNetworks_.size(); }
265-
void killChild(const QString& name);
265+
void killChild(const QString& name, bool force);
266266
void sendItemsToParent();
267267
bool containsModule(const std::string& moduleId) const;
268268

@@ -377,6 +377,7 @@ namespace Gui {
377377
void dumpSubnetworksImpl(const QString& name, Dataflow::Networks::Subnetworks& data, Dataflow::Networks::ModuleFilter modFilter) const;
378378
QList<QGraphicsItem*> includeConnections(QList<QGraphicsItem*> items) const;
379379
QRectF visibleRect() const;
380+
void deleteImpl(QList<QGraphicsItem*> items);
380381

381382
// default constructed
382383
bool modulesSelectedByCL_{ false };

src/Interface/Application/Port.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ void PortWidget::doMousePress(Qt::MouseButton button, const QPointF& pos)
289289
}
290290
else
291291
{
292-
//qDebug() << "mouse press sth else";
293292
}
294293
}
295294

@@ -308,7 +307,6 @@ QGraphicsItem* PortWidget::doMouseMove(Qt::MouseButtons buttons, const QPointF&
308307
}
309308
else
310309
{
311-
//qDebug() << "mouse move sth else";
312310
}
313311
return nullptr;
314312
}
@@ -341,7 +339,6 @@ void PortWidget::doMouseRelease(Qt::MouseButton button, const QPointF& pos, Qt::
341339
}
342340
else
343341
{
344-
//qDebug() << "mouse release sth else";
345342
}
346343
}
347344

src/Interface/Application/SCIRunMainWindow.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,6 @@ bool SCIRunMainWindow::loadNetworkFile(const QString& filename, bool isTemporary
618618
if (command.execute())
619619
{
620620
networkProgressBar_->updateTotalModules(networkEditor_->numModules());
621-
622621
if (!isTemporary)
623622
{
624623
setCurrentFile(filename);

src/Interface/Application/Subnetworks.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ NetworkEditor::~NetworkEditor()
6565
{
6666
child.second->get()->controller_.reset();
6767
delete child.second->get();
68+
delete child.second;
6869
child.second = nullptr;
6970
}
71+
childrenNetworks_.clear();
7072

7173
Q_FOREACH(QGraphicsItem* item, scene_->items())
7274
{
@@ -363,7 +365,7 @@ void NetworkEditor::initializeSubnet(const QString& name, ModuleHandle mod, Netw
363365

364366
auto dock = new SubnetworkEditor(subnet, mod->get_id(), name, nullptr);
365367
dock->setStyleSheet(SCIRunMainWindow::Instance()->styleSheet());
366-
368+
dock->setWindowFlags(dock->windowFlags() | Qt::WindowStaysOnTopHint);
367369
dock->show();
368370
subnet->centerView();
369371

@@ -733,7 +735,7 @@ SubnetWidget::SubnetWidget(NetworkEditor* ed, const QString& name, ModuleHandle
733735

734736
SubnetWidget::~SubnetWidget()
735737
{
736-
editor_->killChild(name_);
738+
editor_->killChild(name_, deleteSubnetImmediately_);
737739
}
738740

739741
SubnetPortsBridgeWidget::SubnetPortsBridgeWidget(NetworkEditor* ed, const QString& name, QWidget* parent /* = 0 */) :
@@ -744,13 +746,16 @@ SubnetPortsBridgeWidget::SubnetPortsBridgeWidget(NetworkEditor* ed, const QStrin
744746
setStyleSheet(rounded + " background-color: darkGray");
745747
}
746748

747-
void NetworkEditor::killChild(const QString& name)
749+
void NetworkEditor::killChild(const QString& name, bool force)
748750
{
749751
auto subnetIter = childrenNetworks_.find(name);
750752
if (subnetIter != childrenNetworks_.end())
751753
{
752754
subnetIter->second->get()->clear();
753-
subnetIter->second->deleteLater();
755+
if (force)
756+
delete subnetIter->second;
757+
else
758+
subnetIter->second->deleteLater();
754759
childrenNetworks_.erase(subnetIter);
755760
currentSubnetNames_.remove(name);
756761
}
@@ -802,7 +807,6 @@ bool SubnetModuleConnector::signalFromSubnet(QObject* sender) const
802807

803808
void SubnetModuleConnector::moduleAddedToSubnet(const std::string& s, ModuleHandle module)
804809
{
805-
//qDebug() << __FUNCTION__ << sender() << signalFromSubnet(sender()) << signalFromParent(sender());
806810
if (signalFromSubnet(sender()) && subnet_->containsModule(module->get_id().id_))
807811
{
808812
qDebug() << "was:" << module_->underlyingModules_.size();
@@ -824,5 +828,4 @@ bool NetworkEditor::containsModule(const std::string& id) const
824828

825829
void SubnetModuleConnector::connectionDeletedFromParent()
826830
{
827-
qDebug() << __FUNCTION__;
828831
}

src/Interface/Modules/Base/ModuleButtonBar.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ void ModuleButtonBar::setTitleVisible(bool visible)
6969
void ModuleButtonBar::switchIcons()
7070
{
7171
//TODO
72-
//qDebug() << collapseToolButton_->styleSheet();
7372
//collapseToolButton_->setIcon(QApplication::style()->standardIcon(QStyle::SP_TitleBarShadeButton));
7473
//collapseToolButton_->setIcon(QApplication::style()->standardIcon(QStyle::SP_TitleBarUnshadeButton));
7574
}

src/Interface/Modules/Base/ModuleDialogGeneric.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -881,12 +881,8 @@ void ModuleDialogGeneric::syncTableRowsWithDynamicPort(const std::string& portId
881881
ScopedWidgetSignalBlocker swsb(table);
882882
if (portId.find(type) != std::string::npos)
883883
{
884-
//qDebug() << "adjust input table: " << portId.c_str() << portChangeType;
885-
886884
if (portChangeType == DynamicPortChange::USER_ADDED_PORT || portChangeType == DynamicPortChange::USER_ADDED_PORT_DURING_FILE_LOAD)
887885
{
888-
//qDebug() << "trying to add row via port added, id: " << portId.c_str();
889-
890886
int connectedPortNumber;
891887
std::string connectedPortId;
892888
std::tie(connectedPortId, connectedPortNumber) = getConnectedDynamicPortId(portId, type, portChangeType == DynamicPortChange::USER_ADDED_PORT_DURING_FILE_LOAD);
@@ -917,7 +913,6 @@ void ModuleDialogGeneric::syncTableRowsWithDynamicPort(const std::string& portId
917913

918914
addLineEditManager(lineEdit, name);
919915
table->setCellWidget(newRowIndex, lineEditIndex, lineEdit);
920-
//qDebug() << "row added with " << lineEditText;
921916

922917
for (int i = 1; i < table->columnCount(); ++i)
923918
{
@@ -942,14 +937,12 @@ void ModuleDialogGeneric::syncTableRowsWithDynamicPort(const std::string& portId
942937
}
943938
else
944939
{
945-
//qDebug() << "trying to remove row with " << portId.c_str();
946940
auto items = table->findItems(QString::fromStdString(portId), Qt::MatchFixedString);
947941
if (!items.empty())
948942
{
949943
auto item = items[0];
950944
int row = table->row(item);
951945
table->removeRow(row);
952-
//qDebug() << "row removed" << QString::fromStdString(portId);
953946
removeManager(Name(portId));
954947
}
955948
else

0 commit comments

Comments
 (0)