Skip to content

Commit ccbc304

Browse files
tsujanyan12125
authored andcommitted
Fixed a crash in context menu
The context menu needs a parent for being positioned correctly under Wayland (→ 27f2e7c). But the parent shouldn't be `TermWidgetImpl` because, otherwise, the app will crash on clicking the action `SUB_COLLAPSE` (which deletes the parent before the menu is closed). The patch prevents the crash by choosing the main window as the parent.
1 parent 8f1c040 commit ccbc304

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/termwidget.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,13 @@ void TermWidgetImpl::propertiesChanged()
137137

138138
void TermWidgetImpl::customContextMenuCall(const QPoint & pos)
139139
{
140-
QMenu menu(this);
141-
QMap<QString, QAction*> actions = findParent<MainWindow>(this)->leaseActions();
140+
auto mainWindow = findParent<MainWindow>(this);
141+
if (mainWindow == nullptr)
142+
{
143+
return;
144+
}
145+
QMenu menu(mainWindow);
146+
QMap<QString, QAction*> actions = mainWindow->leaseActions();
142147

143148
QList<QAction*> extraActions = filterActions(pos);
144149
for (auto& action : extraActions)

0 commit comments

Comments
 (0)