Fix duplicated application menu items on Mac OS
Added code to check to see if the menu item already exists in the application menu before adding it. Change-Id: Ie0a5eab3c61d5a3413a834d2e57bab40660f6802 Task-number: QTBUG-27202 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
865a5f0cda
commit
d1f2309166
@ -195,7 +195,7 @@ NSMenuItem *QCocoaMenuItem::sync()
|
||||
QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
|
||||
switch (m_role) {
|
||||
case ApplicationSpecificRole:
|
||||
mergeItem = [loader appSpecificMenuItem];
|
||||
mergeItem = [loader appSpecificMenuItem:reinterpret_cast<NSInteger>(this)];
|
||||
break;
|
||||
case AboutRole:
|
||||
mergeItem = [loader aboutMenuItem];
|
||||
|
@ -79,7 +79,7 @@
|
||||
- (NSMenuItem *)aboutMenuItem;
|
||||
- (NSMenuItem *)aboutQtMenuItem;
|
||||
- (NSMenuItem *)hideMenuItem;
|
||||
- (NSMenuItem *)appSpecificMenuItem;
|
||||
- (NSMenuItem *)appSpecificMenuItem:(NSInteger)tag;
|
||||
- (IBAction)terminate:(id)sender;
|
||||
- (IBAction)orderFrontStandardAboutPanel:(id)sender;
|
||||
- (IBAction)hideOtherApplications:(id)sender;
|
||||
|
@ -246,11 +246,17 @@ QT_END_NAMESPACE
|
||||
return [[hideItem retain] autorelease];
|
||||
}
|
||||
|
||||
- (NSMenuItem *)appSpecificMenuItem
|
||||
- (NSMenuItem *)appSpecificMenuItem:(NSInteger)tag
|
||||
{
|
||||
NSMenuItem *item = [appMenu itemWithTag:tag];
|
||||
|
||||
// No reason to create the item if it already exists. See QTBUG-27202.
|
||||
if (item)
|
||||
return [[item retain] autorelease];
|
||||
|
||||
// Create an App-Specific menu item, insert it into the menu and return
|
||||
// it as an autorelease item.
|
||||
NSMenuItem *item = [[NSMenuItem alloc] init];
|
||||
item = [[NSMenuItem alloc] init];
|
||||
|
||||
NSInteger location;
|
||||
if (lastAppSpecificItem == nil) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user