summaryrefslogtreecommitdiff
path: root/vcl/aqua/source/app/vclnsapp.mm
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-11-18 15:28:06 +0100
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-11-18 15:28:06 +0100
commit140e83be45834d050d91cd7fad5984f690be09d4 (patch)
treee5afc5c0daace7918d8a169b16a0fb5e3599067f /vcl/aqua/source/app/vclnsapp.mm
parent5bfa292fa2935335d2bf62a5655099798ed37ae6 (diff)
vcl117: #i114937# give application a hint for cleanup, call DeInitVCL
Diffstat (limited to 'vcl/aqua/source/app/vclnsapp.mm')
-rwxr-xr-xvcl/aqua/source/app/vclnsapp.mm120
1 files changed, 67 insertions, 53 deletions
diff --git a/vcl/aqua/source/app/vclnsapp.mm b/vcl/aqua/source/app/vclnsapp.mm
index caa506772272..df089fe17cb1 100755
--- a/vcl/aqua/source/app/vclnsapp.mm
+++ b/vcl/aqua/source/app/vclnsapp.mm
@@ -358,71 +358,85 @@
-(NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication *) app
{
- YIELD_GUARD;
-
+ bool bCallDeInit = false;
NSApplicationTerminateReply aReply = NSTerminateNow;
-
- SalData* pSalData = GetSalData();
- #if 1 // currently do some really bad hack
- if( ! pSalData->maFrames.empty() )
{
- /* #i92766# something really weird is going on with the retain count of
- our windows; sometimes we get a duplicate free before exit on one of our
- NSWindows. The reason is unclear; to avoid this currently we retain them once more
-
- FIXME: this is a really bad hack, relying on the system to catch the leaked
- resources. Find out what really goes on here and fix it !
- */
- std::vector< NSWindow* > aHackRetainedWindows;
- for( std::list< AquaSalFrame* >::iterator it = pSalData->maFrames.begin();
- it != pSalData->maFrames.end(); ++it )
- {
- #if OSL_DEBUG_LEVEL > 1
- Window* pWin = (*it)->GetWindow();
- String aTitle = pWin->GetText();
- Window* pClient = pWin->ImplGetClientWindow();
- fprintf( stderr, "retaining %p (old count %d) windowtype=%s clienttyp=%s title=%s\n",
- (*it)->mpWindow, [(*it)->mpWindow retainCount],
- typeid(*pWin).name(), pClient ? typeid(*pClient).name() : "<nil>",
- rtl::OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 ).getStr()
- );
- #endif
- [(*it)->mpWindow retain];
- aHackRetainedWindows.push_back( (*it)->mpWindow );
- }
- if( pSalData->maFrames.front()->CallCallback( SALEVENT_SHUTDOWN, NULL ) )
+ YIELD_GUARD;
+
+ SalData* pSalData = GetSalData();
+ #if 0 // currently do some really bad hack
+ if( ! pSalData->maFrames.empty() )
{
- for( std::vector< NSWindow* >::iterator it = aHackRetainedWindows.begin();
- it != aHackRetainedWindows.end(); ++it )
+ /* #i92766# something really weird is going on with the retain count of
+ our windows; sometimes we get a duplicate free before exit on one of our
+ NSWindows. The reason is unclear; to avoid this currently we retain them once more
+
+ FIXME: this is a really bad hack, relying on the system to catch the leaked
+ resources. Find out what really goes on here and fix it !
+ */
+ std::vector< NSWindow* > aHackRetainedWindows;
+ for( std::list< AquaSalFrame* >::iterator it = pSalData->maFrames.begin();
+ it != pSalData->maFrames.end(); ++it )
{
- // clean up the retaing count again from the shutdown workaround
#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "releasing %p\n", (*it) );
+ Window* pWin = (*it)->GetWindow();
+ String aTitle = pWin->GetText();
+ Window* pClient = pWin->ImplGetClientWindow();
+ fprintf( stderr, "retaining %p (old count %d) windowtype=%s clienttyp=%s title=%s\n",
+ (*it)->mpWindow, [(*it)->mpWindow retainCount],
+ typeid(*pWin).name(), pClient ? typeid(*pClient).name() : "<nil>",
+ rtl::OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
#endif
- [(*it) release];
+ [(*it)->mpWindow retain];
+ aHackRetainedWindows.push_back( (*it)->mpWindow );
}
- aReply = NSTerminateCancel;
+ if( pSalData->maFrames.front()->CallCallback( SALEVENT_SHUTDOWN, NULL ) )
+ {
+ for( std::vector< NSWindow* >::iterator it = aHackRetainedWindows.begin();
+ it != aHackRetainedWindows.end(); ++it )
+ {
+ // clean up the retaing count again from the shutdown workaround
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "releasing %p\n", (*it) );
+ #endif
+ [(*it) release];
+ }
+ aReply = NSTerminateCancel;
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ for( std::list< AquaSalFrame* >::iterator it = pSalData->maFrames.begin();
+ it != pSalData->maFrames.end(); ++it )
+ {
+ Window* pWin = (*it)->GetWindow();
+ String aTitle = pWin->GetText();
+ Window* pClient = pWin->ImplGetClientWindow();
+ fprintf( stderr, "frame still alive: NSWindow %p windowtype=%s clienttyp=%s title=%s\n",
+ (*it)->mpWindow, typeid(*pWin).name(), pClient ? typeid(*pClient).name() : "<nil>",
+ rtl::OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
+ }
+ #endif
}
- #if OSL_DEBUG_LEVEL > 1
- for( std::list< AquaSalFrame* >::iterator it = pSalData->maFrames.begin();
- it != pSalData->maFrames.end(); ++it )
+ #else // the clean version follows
+ if( ! pSalData->maFrames.empty() )
+ aReply = pSalData->maFrames.front()->CallCallback( SALEVENT_SHUTDOWN, NULL ) ? NSTerminateCancel : NSTerminateNow;
+ #endif
+
+ if( aReply != NSTerminateNow )
+ [NSApp activateIgnoringOtherApps: YES];
+ else
{
- Window* pWin = (*it)->GetWindow();
- String aTitle = pWin->GetText();
- Window* pClient = pWin->ImplGetClientWindow();
- fprintf( stderr, "frame still alive: NSWindow %p windowtype=%s clienttyp=%s title=%s\n",
- (*it)->mpWindow, typeid(*pWin).name(), pClient ? typeid(*pClient).name() : "<nil>",
- rtl::OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 ).getStr()
- );
+ ApplicationEvent aEv( String(), ApplicationAddress(), ByteString( "PRIVATE:DOSHUTDOWN" ), String() );
+ GetpApp()->AppEvent( aEv );
+ // call DeInitVCL only after our YIELD_GUARD has expired,
+ // else its Mutex will be alredy destroyed when it runs out of scope !
+ bCallDeInit = true;
}
- #endif
}
- #else // the clean version follows
- aReply = pSalData->maFrames.front()->CallCallback( SALEVENT_SHUTDOWN, NULL ) ? NSTerminateCancel : NSTerminateNow;
- #endif
+ if( bCallDeInit )
+ DeInitVCL();
- if( aReply != NSTerminateNow )
- [NSApp activateIgnoringOtherApps: YES];
return aReply;
}