Mac: Fix various memory leaks

Change-Id: Id554be11ffcf9a506c217b0dc5b96cb37c4dd57c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2013-04-17 11:27:43 +02:00 committed by The Qt Project
parent 2bd846f8da
commit b381581579
4 changed files with 8 additions and 5 deletions

View File

@ -122,7 +122,9 @@ void QCocoaScreen::updateGeometry()
m_physicalSize = QSizeF(size.width, size.height);
m_logicalDpi.first = 72;
m_logicalDpi.second = 72;
float refresh = CGDisplayModeGetRefreshRate(CGDisplayCopyDisplayMode(dpy));
CGDisplayModeRef displayMode = CGDisplayCopyDisplayMode(dpy);
float refresh = CGDisplayModeGetRefreshRate(displayMode);
CGDisplayModeRelease(displayMode);
if (refresh > 0)
m_refreshRate = refresh;

View File

@ -323,7 +323,8 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf
// typical use-case for a choice list, or non-editable combobox. We can't
// re-use the popUpContextMenu:withEvent:forView: logic below since it won't
// respect the menu's minimum width.
NSPopUpButtonCell *popupCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO];
NSPopUpButtonCell *popupCell = [[[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO]
autorelease];
[popupCell setAltersStateOfSelectedItem:NO];
[popupCell setTransparent:YES];
[popupCell setMenu:m_nativeMenu];
@ -350,7 +351,6 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf
eventNumber:0
clickCount:1
pressure:1.0];
NSSize size = m_nativeMenu.size;
[NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view];
}

View File

@ -176,7 +176,7 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
QHash<QPlatformTheme::Palette, QPalette*> palettes;
QColor qc;
for (int i = 0; mac_widget_colors[i].paletteRole != QPlatformTheme::NPalettes; i++) {
QPalette pal = *qt_mac_createSystemPalette();
QPalette &pal = *qt_mac_createSystemPalette();
if (mac_widget_colors[i].active != 0) {
qc = qt_mac_colorForThemeTextColor(mac_widget_colors[i].active);
pal.setColor(QPalette::Active, QPalette::Text, qc);
@ -223,7 +223,7 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
pal.setBrush(QPalette::Disabled, QPalette::Base,
pal.brush(QPalette::Active, QPalette::Base));
}
palettes.insert(mac_widget_colors[i].paletteRole, new QPalette(pal));
palettes.insert(mac_widget_colors[i].paletteRole, &pal);
}
return palettes;
}

View File

@ -1785,6 +1785,7 @@ QMacStyle::~QMacStyle()
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
[[NSNotificationCenter defaultCenter] removeObserver:receiver];
[receiver release];
}
#endif