diff --git a/extern/nfd-modified/src/nfd_cocoa.mm b/extern/nfd-modified/src/nfd_cocoa.mm index ac5fa36c4..8eac6f795 100644 --- a/extern/nfd-modified/src/nfd_cocoa.mm +++ b/extern/nfd-modified/src/nfd_cocoa.mm @@ -18,6 +18,8 @@ static NSArray *BuildAllowedFileTypes( const char *filterList ) { // Commas and semicolons are the same thing on this platform + // like what about THIS INSTEAD! + // NSMutableArray *buildFilterList = NSMutableArray::alloc()->init(); NSMutableArray *buildFilterList = [[NSMutableArray alloc] init]; char typebuf[NFD_MAX_STRLEN] = {0}; @@ -32,6 +34,9 @@ static NSArray *BuildAllowedFileTypes( const char *filterList ) ++p_typebuf; *p_typebuf = '\0'; + // or this: NSString::stringWithUTF8String(typebuf); + // buildFilterList->addObject(thisType); + // really? did you have to make this mess?! NSString *thisType = [NSString stringWithUTF8String: typebuf]; [buildFilterList addObject:thisType]; p_typebuf = typebuf; diff --git a/src/gui/fileDialog.cpp b/src/gui/fileDialog.cpp index 5be3bdb1a..64f9e989e 100644 --- a/src/gui/fileDialog.cpp +++ b/src/gui/fileDialog.cpp @@ -67,7 +67,11 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector filter, c if (sysDialog) { #ifdef USE_NFD dialogOK=false; +#ifdef NFD_NON_THREADED + _nfdThread(NFDState(false,header,filter,path,clickCallback),&dialogOK,&nfdResult); +#else dialogO=new std::thread(_nfdThread,NFDState(false,header,filter,path,clickCallback),&dialogOK,&nfdResult); +#endif #else dialogO=new pfd::open_file(header,path,filter); #endif @@ -87,7 +91,11 @@ bool FurnaceGUIFileDialog::openSave(String header, std::vector filter, c if (sysDialog) { #ifdef USE_NFD dialogOK=false; +#ifdef NFD_NON_THREADED + _nfdThread(NFDState(true,header,filter,path,NULL),&dialogOK,&nfdResult); +#else dialogS=new std::thread(_nfdThread,NFDState(true,header,filter,path,NULL),&dialogOK,&nfdResult); +#endif #else dialogS=new pfd::save_file(header,path,filter); #endif diff --git a/src/gui/fileDialog.h b/src/gui/fileDialog.h index 6131f56b2..6724eb951 100644 --- a/src/gui/fileDialog.h +++ b/src/gui/fileDialog.h @@ -10,6 +10,11 @@ #ifdef USE_NFD #include #include + +#ifdef __APPLE__ +#define NFD_NON_THREADED +#endif + #else namespace pfd { class open_file; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5717f3910..dc45acf49 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3138,6 +3138,7 @@ bool FurnaceGUI::loop() { #endif } +#ifndef NFD_NON_THREADED if (fileDialog->isOpen() && settings.sysFileDialog) { ImGui::OpenPopup("System File Dialog Pending"); } @@ -3150,6 +3151,7 @@ bool FurnaceGUI::loop() { dl->AddRectFilled(ImVec2(0.0f,0.0f),ImVec2(scrW*dpiScale,scrH*dpiScale),ImGui::ColorConvertFloat4ToU32(uiColors[GUI_COLOR_MODAL_BACKDROP])); ImGui::EndPopup(); } +#endif if (fileDialog->render(ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) { bool openOpen=false;