Skip to content

Commit

Permalink
fix NCriticalPathWidget termination, previous approach was not reliab…
Browse files Browse the repository at this point in the history
…le, since to async connection nature and using same signal in few different places
  • Loading branch information
w0lek committed Nov 13, 2023
1 parent 53466ab commit 43e1471
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
16 changes: 1 addition & 15 deletions src/Main/Tasks_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,7 @@ void openInteractivePathAnalysisView(Compiler* compiler) {

if (newView) {
NCriticalPathWidget* viewWidget = new NCriticalPathWidget(compiler);

// TODO: make it generic, and check how this was handled for other tab content (issue logged to https://github.com/os-fpga/FOEDAG/issues/1372)
QObject::connect(tabWidget, &QTabWidget::tabCloseRequested, [tabWidget, viewName, viewWidget](){
bool found{false};
for (int i = 0; i < tabWidget->count(); i++) {
if (tabWidget->tabText(i) == viewName) {
found = true;
break;
}
}

if (!found) {
viewWidget->deleteLater();
}
});
viewWidget->setProperty("deleteOnClose", true);

tabWidget->addTab(viewWidget, viewName);
tabWidget->setCurrentWidget(viewWidget);
Expand Down
12 changes: 11 additions & 1 deletion src/TextEditor/text_editor_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ void TextEditorForm::SlotTabCloseRequested(int index) {
return;
}

Editor *tabItem = qobject_cast<Editor *>(m_tab_editor->widget(index));
// TODO: with removing property "deleteOnClose" it may become possible solution for https://github.com/os-fpga/FOEDAG/issues/1372
QWidget* page = m_tab_editor->widget(index);
if (page) {
QVariant value = page->property("deleteOnClose");
if (value.isValid() && value.toBool()) {
page->deleteLater();
}
}

Editor *tabItem = qobject_cast<Editor *>(page);
if (!tabItem) {
m_tab_editor->removeTab(index);
return;
Expand All @@ -159,6 +168,7 @@ void TextEditorForm::SlotTabCloseRequested(int index) {
m_map_file_tabIndex_editor.erase(iter);
m_fileWatcher.removePath(iter.key());
}

// Removes the tab at position index from this stack of widgets.
// The page widget itself is not deleted.
m_tab_editor->removeTab(index);
Expand Down

0 comments on commit 43e1471

Please sign in to comment.