From c5809ade611d93c165dbde8c6ee618da73b0ad48 Mon Sep 17 00:00:00 2001 From: Nils Jeisecke Date: Wed, 13 Jan 2010 11:14:42 +0100 Subject: Memory leak in native Toolbar cleanup in Cocoa The QCocoaToolBarDelegate is not released when destroying the QMainWindowLayout. Task-number: QTBUG-7307 Reviewed-by: Prasanth Ullattil --- src/gui/widgets/qmainwindowlayout_mac.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm index e41c2be..ee79f5a 100644 --- a/src/gui/widgets/qmainwindowlayout_mac.mm +++ b/src/gui/widgets/qmainwindowlayout_mac.mm @@ -476,6 +476,17 @@ void QMainWindowLayout::cleanUpMacToolbarItems() CFRelease(toolbarItemsCopy.at(i)); toolbarItemsCopy.clear(); unifiedToolbarHash.clear(); + +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + + OSWindowRef window = qt_mac_window_for(layoutState.mainWindow); + NSToolbar *macToolbar = [window toolbar]; + if (macToolbar) { + [[macToolbar delegate] release]; + [macToolbar setDelegate:nil]; + } +#endif } void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const -- cgit v0.12