summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-09-27 11:14:48 +0200
committerSergio Ahumada <sergio.ahumada@digia.com>2013-09-27 11:15:09 +0200
commit16a36239ab9e9be45a940aeff94f35e29bdeb944 (patch)
treeed6c159f12fa2ff80cf39b97a65eab0546ffe639 /examples
parente37001aad7f6e4bbad250addba033f1eaf97d566 (diff)
parent00da2e615e89c46affbc130b4df6148785724a23 (diff)
Merge branch 'stable' into dev
Diffstat (limited to 'examples')
-rw-r--r--examples/widgets/mac/qmacnativewidget/main.mm25
1 files changed, 17 insertions, 8 deletions
diff --git a/examples/widgets/mac/qmacnativewidget/main.mm b/examples/widgets/mac/qmacnativewidget/main.mm
index 28cf2adc3b..4558143b75 100644
--- a/examples/widgets/mac/qmacnativewidget/main.mm
+++ b/examples/widgets/mac/qmacnativewidget/main.mm
@@ -79,12 +79,14 @@ char **qtArgv;
QApplication *qtApp = 0;
}
-@interface WindowCreator : NSObject {}
-- (void)createWindow;
+@interface WindowCreator : NSObject <NSApplicationDelegate>
@end
@implementation WindowCreator
-- (void)createWindow {
+
+- (void)applicationDidFinishLaunching:(NSNotification *)notification
+{
+ Q_UNUSED(notification)
// Qt widgets rely on a QApplication being alive somewhere
qtApp = new QApplication(qtArgc, qtArgv);
@@ -120,18 +122,25 @@ QApplication *qtApp = 0;
// Show the NSWindow
[window makeKeyAndOrderFront:NSApp];
}
+
+- (void)applicationWillTerminate:(NSNotification *)notification
+{
+ Q_UNUSED(notification)
+
+ delete qtApp;
+}
+
@end
int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ Q_UNUSED(pool);
- // Normally, we would use the application delegate.
- // We resort to the notification mechanism for conciseness.
+ // Normally, we would use let the main bundle instanciate and set
+ // the application delegate, but we set it manually for conciseness.
WindowCreator *windowCreator= [WindowCreator alloc];
- [[NSNotificationCenter defaultCenter]
- addObserver:windowCreator selector:@selector(createWindow)
- name:NSApplicationDidFinishLaunchingNotification object:nil];
+ [[NSApplication sharedApplication] setDelegate:windowCreator];
// Save these for QApplication
qtArgc = argc;