BT: Fix a crash in the SDI example in Cocoa
commitff612d143bbf03443d562233db7a5c014090e88c
authorNorwegian Rock Cat <qt-info@nokia.com>
Wed, 3 Jun 2009 13:25:46 +0000 (3 15:25 +0200)
committerJason McDonald <jason.mcdonald@nokia.com>
Thu, 4 Jun 2009 03:43:30 +0000 (4 13:43 +1000)
treecb1ad2e8143308c45f3a126e554be6f90fdf5a7b
parentd04ea0a42e3eaf07afc8bd80cbd6a1319968aae8
BT: Fix a crash in the SDI example in Cocoa

This was quite a bug and it showed to some issues that I hadn't taken
into account when doing the initial port to Cocoa. The issue was that we
weren't "merging" items into the application menu if an item had already
been associated with it. Which seems OK for applications that create one
window with one menubar, but breaks down horrible when you have multiple
windows with each having their own menubar. The result is that items in
the application menu potentially go to the wrong window (and the
potential crash). Since there can only ever be one "Quit", "About", or
"Preferences" menu item in Cocoa, we need to make sure that we keep
these items in sync whenever we switch the menubar or remove actions
that are being deleted. That's what we do here.

FWIW, QActions with "ApplicationSpecificRole" for their menu role have
potential to cause memory leaks or other bugs if abused. If you are a
happy open source hacker who wants a thankless job, solving them would
get you lots of goodwill in my book.

Task-number: 255038
Reviewed-by: Richard Moe Gustavsen
(cherry picked from commit 826b2ec2067e725561db2892dd432c01f1d36bc7)
src/gui/widgets/qmenu_mac.mm