Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for a Qt crash on reloading menus #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tsujan
Copy link
Member

@tsujan tsujan commented Nov 15, 2024

Such random crashes are triggered by Qt → QMenu::timerEvent(). Qt doesn't take into account the possibility of dangling pointers in qmenu.cpp under very rare circumstances, e.g., when the actions of a menu with a visible submenu are recreated too rapidly multiple times (also see https://bugreports.qt.io/browse/QTBUG-77273, although our case is much more complex). That may no be unexpected in a code full of timers and event handling.

To avoid dangling pointers, the patch just puts a minimum interval of two seconds between two consecutive reloads.

It also restores the active action on refreshing, such that a reloaded submenu isn't closed anymore (see lxqt/lxqt#2282 and especially @yan12125's report https://gitlab.gnome.org/GNOME/network-manager-applet/-/issues/195).

Finally, it removes a redundant, recursive computation.

Closes lxqt/lxqt-panel#1802

NOTE: I was able to reproduce the crash easily with nm-applet. Before arriving at this workaround, I tried various ideas but could still make lxqt-panel crash in a few minutes. Only this time I can't, in spite of trying for days.

Such random crashes are triggered by Qt → `QMenu::timerEvent()`. Qt doesn't take into account the possibility of dangling pointers in `qmenu.cpp` under very rare circumstances, e.g., when the actions of a menu with a visible submenu are recreated too rapidly multiple times (also see https://bugreports.qt.io/browse/QTBUG-77273, although our case is much more complex). That may no be unexpected in a code full of timers and event handling.

To avoid dangling pointers, the patch just puts a minimum interval of two seconds between two consecutive reloads.

It also restores the active action on refreshing, such that a reloaded submenu isn't closed anymore (see lxqt/lxqt#2282 and especially @yan12125's report https://gitlab.gnome.org/GNOME/network-manager-applet/-/issues/195).

Finally, it removes a redundant, recursive computation.

Closes lxqt/lxqt-panel#1802

NOTE: I was able to reproduce the crash easily with nm-applet. Before arriving at this workaround, I tried various ideas but could still make lxqt-panel crash in a few minutes. Only this time I can't, in spite of trying for days.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rare crash on showing context menu of notification area item
1 participant