]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/CocoaFileDialog.mm
Support for multiple data dirs.
[flightgear.git] / src / GUI / CocoaFileDialog.mm
index 9f15680e211453097f4b859bc16f65b5646a2581..a16a7892f77c4440de099335529df7875a72da66 100644 (file)
@@ -27,6 +27,11 @@ static NSURL* pathToNSURL(const SGPath& aPath)
     return [NSURL fileURLWithPath:stdStringToCocoa(aPath.str())];
 }
 
+// 10.6 compiler won't accept block-scoped locals in Objective-C++,
+// so making these globals.
+static NSString* completion_path = nil;
+static SGPath completion_sgpath;
+
 class CocoaFileDialog::CocoaFileDialogPrivate
 {
 public:
@@ -74,6 +79,7 @@ void CocoaFileDialog::exec()
     NSWindow* cocoaWindow = nil;
     std::vector<osgViewer::GraphicsWindow*> windows;
     globals->get_renderer()->getViewer()->getWindows(windows);
+    
     BOOST_FOREACH(osgViewer::GraphicsWindow* gw, windows) {
         // OSG doesn't use RTTI, so no dynamic cast. Let's check the class type
         // using OSG's own system, before we blindly static_cast<> and break
@@ -117,10 +123,10 @@ void CocoaFileDialog::exec()
     [d->panel beginSheetModalForWindow:cocoaWindow completionHandler:^(NSInteger result)
     {
         if (result == NSFileHandlingPanelOKButton) {
-            NSString* path = [[d->panel URL] path];
+            completion_path = [[d->panel URL] path];
             //NSLog(@"the URL is: %@", d->panel URL]);
-            SGPath sgpath([path UTF8String]);
-            _callback->onFileDialogDone(this, sgpath);
+            completion_sgpath = ([completion_path UTF8String]);
+            _callback->onFileDialogDone(this, completion_sgpath);
         }
     }];
 }