Skip to content

Commit a5a1071

Browse files
committed
qtui: Always accept closeEvent() on dock windows
Qt 6 appears to send close events to all windows at QApplication termination. Ignoring the event at this point can cause a hang or a crash (due to DockWidget::closeEvent being called twice).
1 parent 5b57d40 commit a5a1071

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/qtui/main_window.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,30 @@ class DockWidget : public QDockWidget
6767
}
6868

6969
protected:
70-
void closeEvent(QCloseEvent * event) override
71-
{
72-
in_event = true;
73-
m_item->user_close();
74-
event->ignore();
75-
in_event = false;
76-
}
70+
void closeEvent(QCloseEvent * event) override { close_for_event(event); }
7771

7872
void keyPressEvent(QKeyEvent * event) override
7973
{
8074
auto mods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier;
8175
if (!(event->modifiers() & mods) && event->key() == Qt::Key_Escape &&
8276
isFloating())
8377
{
84-
in_event = true;
85-
m_item->user_close();
86-
event->accept();
87-
in_event = false;
78+
close_for_event(event);
8879
return;
8980
}
9081

9182
QDockWidget::keyPressEvent(event);
9283
}
9384

9485
private:
86+
void close_for_event(QEvent * event)
87+
{
88+
in_event = true;
89+
m_item->user_close();
90+
in_event = false;
91+
event->accept();
92+
}
93+
9594
audqt::DockItem * m_item;
9695
bool in_event = false;
9796
};

0 commit comments

Comments
 (0)