Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.2.1
-
None
-
OSX 10.8.5 XCode/QtCreator
-
-
a2ce7e6a6f0f5c638aaa644255e9352eb91b57d6
Description
On Windows, QMenu never becomes active but on Mac it does. As a result, on its way out, QApplicationPrivate::focus_window gets cleared by the QWindow destructor for QMenu, leaving the app in a limbo afterwards that shortcuts in the menu bar will always be the one activated, regardless what QWidget actually has the focus. The workaround is to switch to another app then come back.
Attached please find a simple app that repros the problem.
Repro steps:
0) before start, first copy some random text to the clipboard so that we have something to paste into line edit with
1) launched the sample app, the read-only line edit at the top shows the focusWindow the app currently knows about
2) right click (or Ctrl+Click) to bring up the context menu
3) dismiss the context menu
Notice that on Windows the focus window does not change through out the process. But on Mac however, focus window is updated as soon as the menu shows up, and becomes 0x0 when the menu is dismissed.
Once in this state, if you now try to paste into the line edit at the bottom using Ctrl/Cmd+V, what gets pasted won't be from the clipboard as one would expect but rather from the "Global Paste" menu item of the menu bar.
This is because with focus_widget being 0, qApp->focusObject() in menuHasKeyEquivalent in qcocoamenu.mm will always return 0, so the app doesn't think there's a focus widget it needs to consult so it would just go ahead and activate the shortcut in the menubar...
I ran into the issue on Mac with 5.2.1, but it may exist in 5.x versions prior.
Attachments
Issue Links
- replaces
-
QTBUG-33557 [REG] OS X: tilde doesn't appear
- Closed
-
QTBUG-41484 OS X: After show contextMenu, can not input Chinese.
- Closed