Discussion:
Mac: OnExit not called for my app
Joost N
2014-04-17 08:14:18 UTC
Permalink
Hi,

On mac when my app is quit by right clicking on the dock icon,
wxApp::OnExit() and ~wxApp() are not called. Rather NSApplication is
calling directly to exit() which starts to do global cleanup.

The strange thing is that it's working fine when I create a minimal sample.
But the stack trace below shows the problem.

~TjnVirtualMemoryManager is the destructor of a global object for which
I've set a breakpoint. Why is NSApplication calling exit() rather than
returning all the way to stack frame #26 where OnExit would normally be
called? Any help appreciated, thanks!

#0 0x0000000101f675c0 in ~TjnVirtualMemoryManager at
/Volumes/devel/wxwprojects/components/TjnMMF/TjnVirtualMemoryManagerV2.cpp:638

#1 0x0000000101f5df75 in ~TjnVirtualMemoryManager at
/Volumes/devel/wxwprojects/components/TjnMMF/TjnVirtualMemoryManagerV2.cpp:637

#2 0x00007fff8cbb47a1 in __cxa_finalize ()
#3 0x00007fff8cbb4a4c in exit ()
#4 0x00007fff9001b45a in -[NSApplication terminate:] ()
#5 0x00007fff9013dd12 in -[NSApplication
_terminateFromSender:askIfShouldTerminate:saveWindows:] ()
#6 0x00007fff90147d08 in __52-[NSApplication(NSAppleEventHandling)
_handleAEQuit]_block_invoke ()
#7 0x00007fff8edc91d7 in _dispatch_call_block_and_release ()
#8 0x00007fff8edc62ad in _dispatch_client_callout ()
#9 0x00007fff8edcdf03 in _dispatch_main_queue_callback_4CF ()
#10 0x00007fff99ee8679 in
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#11 0x00007fff99ea3954 in __CFRunLoopRun ()
#12 0x00007fff99ea30b5 in CFRunLoopRunSpecific ()
#13 0x00007fff97d02a0d in RunCurrentEventLoopInMode ()
#14 0x00007fff97d02685 in ReceiveNextEventCommon ()
#15 0x00007fff97d025bc in
_BlockUntilNextEventMatchingListInModeWithFilter ()
#16 0x00007fff8fda83de in _DPSNextEvent ()
#17 0x00007fff8fda7a2b in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#18 0x00007fff8fd9bb2c in -[NSApplication run] ()
#19 0x0000000102618f36 in wxGUIEventLoop::OSXDoRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/osx/cocoa/evtloop.mm:286

#20 0x000000010289bc37 in wxCFEventLoop::DoRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/osx/core/evtloop_cf.cpp:340

#21 0x00000001027ddc5b in wxEventLoopBase::Run() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/evtloopcmn.cpp:78

#22 0x000000010279d4a6 in wxAppConsoleBase::MainLoop() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/appbase.cpp:334
#23 0x000000010279d009 in wxAppConsoleBase::OnRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/appbase.cpp:259
#24 0x000000010264efce in wxAppBase::OnRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/appcmn.cpp:304
#25 0x00000001025c0565 in wxApp::OnRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/osx/carbon/app.cpp:915
#26 0x000000010281c825 in wxEntry(int&, wchar_t**) at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/init.cpp:495
#27 0x000000010281c99f in wxEntry(int&, char**) at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/init.cpp:507
#28 0x00000001023f3866 in main at
/Volumes/devel/wxwprojects/PTGuiViewer/source/main.cpp:31
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Stefan Csomor
2014-04-17 15:04:01 UTC
Permalink
Hi Joost

are wxApp::OSXOnShouldTerminate and wxApp::OSXOnWillTerminate called ? if yes, from which level ?

Best,

Stefan

Von: Joost N <***@gmail.com<mailto:***@gmail.com>>
Antworten an: "wx-***@googlegroups.com<mailto:wx-***@googlegroups.com>" <wx-***@googlegroups.com<mailto:wx-***@googlegroups.com>>
Datum: Donnerstag, 17. April 2014 10:14
An: "wx-***@googlegroups.com<mailto:wx-***@googlegroups.com>" <wx-***@googlegroups.com<mailto:wx-***@googlegroups.com>>
Betreff: Mac: OnExit not called for my app

Hi,

On mac when my app is quit by right clicking on the dock icon, wxApp::OnExit() and ~wxApp() are not called. Rather NSApplication is calling directly to exit() which starts to do global cleanup.

The strange thing is that it's working fine when I create a minimal sample. But the stack trace below shows the problem.

~TjnVirtualMemoryManager is the destructor of a global object for which I've set a breakpoint. Why is NSApplication calling exit() rather than returning all the way to stack frame #26 where OnExit would normally be called? Any help appreciated, thanks!

#0 0x0000000101f675c0 in ~TjnVirtualMemoryManager at /Volumes/devel/wxwprojects/components/TjnMMF/TjnVirtualMemoryManagerV2.cpp:638
#1 0x0000000101f5df75 in ~TjnVirtualMemoryManager at /Volumes/devel/wxwprojects/components/TjnMMF/TjnVirtualMemoryManagerV2.cpp:637
#2 0x00007fff8cbb47a1 in __cxa_finalize ()
#3 0x00007fff8cbb4a4c in exit ()
#4 0x00007fff9001b45a in -[NSApplication terminate:] ()
#5 0x00007fff9013dd12 in -[NSApplication _terminateFromSender:askIfShouldTerminate:saveWindows:] ()
#6 0x00007fff90147d08 in __52-[NSApplication(NSAppleEventHandling) _handleAEQuit]_block_invoke ()
#7 0x00007fff8edc91d7 in _dispatch_call_block_and_release ()
#8 0x00007fff8edc62ad in _dispatch_client_callout ()
#9 0x00007fff8edcdf03 in _dispatch_main_queue_callback_4CF ()
#10 0x00007fff99ee8679 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#11 0x00007fff99ea3954 in __CFRunLoopRun ()
#12 0x00007fff99ea30b5 in CFRunLoopRunSpecific ()
#13 0x00007fff97d02a0d in RunCurrentEventLoopInMode ()
#14 0x00007fff97d02685 in ReceiveNextEventCommon ()
#15 0x00007fff97d025bc in _BlockUntilNextEventMatchingListInModeWithFilter ()
#16 0x00007fff8fda83de in _DPSNextEvent ()
#17 0x00007fff8fda7a2b in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#18 0x00007fff8fd9bb2c in -[NSApplication run] ()
#19 0x0000000102618f36 in wxGUIEventLoop::OSXDoRun() at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/osx/cocoa/evtloop.mm:286
#20 0x000000010289bc37 in wxCFEventLoop::DoRun() at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/osx/core/evtloop_cf.cpp:340
#21 0x00000001027ddc5b in wxEventLoopBase::Run() at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/common/evtloopcmn.cpp:78
#22 0x000000010279d4a6 in wxAppConsoleBase::MainLoop() at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/common/appbase.cpp:334
#23 0x000000010279d009 in wxAppConsoleBase::OnRun() at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/common/appbase.cpp:259
#24 0x000000010264efce in wxAppBase::OnRun() at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/common/appcmn.cpp:304
#25 0x00000001025c0565 in wxApp::OnRun() at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/osx/carbon/app.cpp:915
#26 0x000000010281c825 in wxEntry(int&, wchar_t**) at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/common/init.cpp:495
#27 0x000000010281c99f in wxEntry(int&, char**) at /Developer/wxWidgets-3.0.0/build_10.9_debug/../src/common/init.cpp:507
#28 0x00000001023f3866 in main at /Volumes/devel/wxwprojects/PTGuiViewer/source/main.cpp:31

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com<mailto:wx-users+***@googlegroups.com>
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Joost N
2014-04-22 13:05:10 UTC
Permalink
Hi Stefan,

Thanks for the hints. I think I've found and fixed the problem.
Here's the bug report: http://trac.wxwidgets.org/ticket/16200

Joost
Post by Stefan Csomor
Hi Joost
are wxApp::OSXOnShouldTerminate and wxApp::OSXOnWillTerminate called ?
if yes, from which level ?
Best,
Stefan
Datum: Donnerstag, 17. April 2014 10:14
Betreff: Mac: OnExit not called for my app
Hi,
On mac when my app is quit by right clicking on the dock icon,
wxApp::OnExit() and ~wxApp() are not called. Rather NSApplication is
calling directly to exit() which starts to do global cleanup.
The strange thing is that it's working fine when I create a minimal
sample. But the stack trace below shows the problem.
~TjnVirtualMemoryManager is the destructor of a global object for which
I've set a breakpoint. Why is NSApplication calling exit() rather than
returning all the way to stack frame #26 where OnExit would normally be
called? Any help appreciated, thanks!
#0 0x0000000101f675c0 in ~TjnVirtualMemoryManager at
/Volumes/devel/wxwprojects/components/TjnMMF/TjnVirtualMemoryManagerV2.cpp:638
#1 0x0000000101f5df75 in ~TjnVirtualMemoryManager at
/Volumes/devel/wxwprojects/components/TjnMMF/TjnVirtualMemoryManagerV2.cpp:637
#2 0x00007fff8cbb47a1 in __cxa_finalize ()
#3 0x00007fff8cbb4a4c in exit ()
#4 0x00007fff9001b45a in -[NSApplication terminate:] ()
#5 0x00007fff9013dd12 in -[NSApplication
_terminateFromSender:askIfShouldTerminate:saveWindows:] ()
#6 0x00007fff90147d08 in __52-[NSApplication(NSAppleEventHandling)
_handleAEQuit]_block_invoke ()
#7 0x00007fff8edc91d7 in _dispatch_call_block_and_release ()
#8 0x00007fff8edc62ad in _dispatch_client_callout ()
#9 0x00007fff8edcdf03 in _dispatch_main_queue_callback_4CF ()
#10 0x00007fff99ee8679 in
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#11 0x00007fff99ea3954 in __CFRunLoopRun ()
#12 0x00007fff99ea30b5 in CFRunLoopRunSpecific ()
#13 0x00007fff97d02a0d in RunCurrentEventLoopInMode ()
#14 0x00007fff97d02685 in ReceiveNextEventCommon ()
#15 0x00007fff97d025bc in
_BlockUntilNextEventMatchingListInModeWithFilter ()
#16 0x00007fff8fda83de in _DPSNextEvent ()
#17 0x00007fff8fda7a2b in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#18 0x00007fff8fd9bb2c in -[NSApplication run] ()
#19 0x0000000102618f36 in wxGUIEventLoop::OSXDoRun() at *
/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/osx/cocoa/
evtloop.mm:286
#20 0x000000010289bc37 in wxCFEventLoop::DoRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/osx/core/evtloop_cf.cpp:340
#21 0x00000001027ddc5b in wxEventLoopBase::Run() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/evtloopcmn.cpp:78
#22 0x000000010279d4a6 in wxAppConsoleBase::MainLoop() at *
/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/appbase.cpp:334
#23 0x000000010279d009 in wxAppConsoleBase::OnRun() at *
/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/appbase.cpp:259
#24 0x000000010264efce in wxAppBase::OnRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/appcmn.cpp:304
#25 0x00000001025c0565 in wxApp::OnRun() at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/osx/carbon/app.cpp:915
#26 0x000000010281c825 in wxEntry(int&, wchar_t**) at *
/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/init.cpp:495
#27 0x000000010281c99f in wxEntry(int&, char**) at
*/Developer/wxWidgets-3.0.0/build_10.9_debug/*../src/common/init.cpp:507
#28 0x00000001023f3866 in main at
/Volumes/devel/wxwprojects/PTGuiViewer/source/main.cpp:31
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Stefan Csomor
2014-04-17 15:08:24 UTC
Permalink
Hi Joost

And your app does have a proper 'Quit Application' menu item ...

Best,

Stefan
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...