]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/app.cpp
Added const qualifier to char* in struct service_entry
[wxWidgets.git] / src / mac / carbon / app.cpp
index 83406b962384de5bb166d0d55b15fa957c29f396..f610756a2a282f456a2a3ef295a83e1fcb725941 100644 (file)
@@ -366,11 +366,7 @@ static const EventTypeSpec eventList[] =
 
 static pascal OSStatus
 wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
-    EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ;
-    EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ;
-    wxTheApp->MacSetCurrentEvent( event , handler ) ;
-    
+{    
     wxMacCarbonEvent cEvent( event ) ;
     MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ;
     wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ;
@@ -416,8 +412,6 @@ wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *d
             }
     }
     
-    wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ;
-
     return eventNotHandledErr;
 }
 
@@ -502,6 +496,10 @@ static pascal OSStatus wxMacAppApplicationEventHandler( EventHandlerCallRef hand
 
 pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
 {
+    EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ;
+    EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ;
+    wxTheApp->MacSetCurrentEvent( event , handler ) ;
+
     OSStatus result = eventNotHandledErr ;
     switch( GetEventClass( event ) )
     {
@@ -528,6 +526,8 @@ pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef eve
             break ;
     }
 
+    wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ;
+
     return result ;
 }
 
@@ -635,18 +635,12 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     wxString startupCwd = wxGetCwd() ;
     if ( startupCwd == wxT("/") || startupCwd.Right(15) == wxT("/Contents/MacOS") )
     {
-        wxString cwd ;
         CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle() ) ;
         CFURLRef urlParent = CFURLCreateCopyDeletingLastPathComponent( kCFAllocatorDefault , url ) ;
         CFRelease( url ) ;
         CFStringRef path = CFURLCopyFileSystemPath ( urlParent , kCFURLPOSIXPathStyle ) ;
         CFRelease( urlParent ) ;
-        CFIndex len = CFStringGetLength( path )  ;
-        CFIndex max = CFStringGetMaximumSizeForEncoding( len, kCFStringEncodingUTF8 ) ;
-        wxChar* buf = cwd.GetWriteBuf( max ) ;
-        CFStringGetCString( path , buf , max + 1 , kCFStringEncodingUTF8 ) ;
-        CFRelease( path ) ;
-        cwd.UngetWriteBuf() ;
+        wxString cwd = wxMacCFStringHolder(path).AsString(wxLocale::GetSystemEncoding());       
         wxSetWorkingDirectory( cwd ) ;
     }
 #endif