From: rambetter Date: Sun, 19 Dec 2010 04:12:29 +0000 (+0000) Subject: Cleaning up some file dialog tidbits in Rambetter-temp-fixes branch. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=070176f828be1c226e0f4f84061d6d005640b1e2;p=xonotic%2Fnetradiant.git Cleaning up some file dialog tidbits in Rambetter-temp-fixes branch. Just some code maintenence. Like removing unused local vars. PLS MERGE TO TRUNK. git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/branches/Rambetter-temp-fixes@356 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 9d584f43..93fed4a0 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -1203,13 +1203,11 @@ private: #ifdef _WIN32 -static int in_file_dialog = 0; - typedef struct { gboolean open; OPENFILENAME *ofn; BOOL dlgRtnVal; - int done; + bool done; } win32_native_file_dialog_comms_t; DWORD WINAPI win32_native_file_dialog_thread_func(LPVOID lpParam) @@ -1222,7 +1220,7 @@ DWORD WINAPI win32_native_file_dialog_thread_func(LPVOID lpParam) else { fileDialogComms->dlgRtnVal = GetSaveFileName(fileDialogComms->ofn); } - fileDialogComms->done = -1; // No need to synchronize around lock. + fileDialogComms->done = true; // No need to synchronize around lock, one-way gate. return 0; } @@ -1235,14 +1233,14 @@ const char* file_dialog (void *parent, gboolean open, const char* title, const c { #ifdef _WIN32 + static bool in_file_dialog = false; HANDLE fileDialogThreadHandle; win32_native_file_dialog_comms_t fileDialogComms; - int dialogDone; + bool dialogDone; #endif // Gtk dialog GtkWidget* file_sel; - int loop = 1; char *new_path = NULL; const char* r; @@ -1258,7 +1256,7 @@ const char* file_dialog (void *parent, gboolean open, const char* title, const c // do that the native way if (in_file_dialog) return NULL; // Avoid recursive entry. - in_file_dialog = 1; + in_file_dialog = true; /* Set the members of the OPENFILENAME structure. */ // See http://msdn.microsoft.com/en-us/library/ms646839%28v=vs.85%29.aspx . memset(&ofn, 0, sizeof(ofn)); @@ -1305,16 +1303,16 @@ const char* file_dialog (void *parent, gboolean open, const char* title, const c 0, // dwCreationFlags NULL); // lpThreadId - dialogDone = 0; + dialogDone = false; while (1) { - // Avoid blocking indefinitely. Another thread will set fileDialogComms->done to nonzero; + // Avoid blocking indefinitely. Another thread will set fileDialogComms->done to true; // we don't want to be in an indefinite blocked state when this happens. We want to break // out of here eventually. while (gtk_events_pending()) { gtk_main_iteration(); } if (dialogDone) break; - if (fileDialogComms.done) dialogDone = 1; // One more loop of gtk_main_iteration() to get things in sync. + if (fileDialogComms.done) dialogDone = true; // One more loop of gtk_main_iteration() to get things in sync. // Avoid tight infinte loop, add a small amount of sleep. Sleep(10); } @@ -1322,7 +1320,7 @@ const char* file_dialog (void *parent, gboolean open, const char* title, const c WaitForSingleObject(fileDialogThreadHandle, INFINITE); CloseHandle(fileDialogThreadHandle); - in_file_dialog = 0; + in_file_dialog = false; if (!fileDialogComms.dlgRtnVal) { return NULL; // Cancelled. diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index a741e219..821f44c3 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -2218,7 +2218,7 @@ void PrefsDlg::BuildDialog () #ifdef _WIN32 // win32 file dialog - check = gtk_check_button_new_with_label (_("Use win32 file load dialog (hacky)")); + check = gtk_check_button_new_with_label (_("Use win32 file dialog (hacky)")); gtk_widget_show (check); // gtk_container_add (GTK_CONTAINER (vbox), check); gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);