Index: dialog.h =================================================================== RCS file: /cvs/cygwin-apps/setup/dialog.h,v retrieving revision 2.9 diff -p -u -b -r2.9 dialog.h --- dialog.h 23 Jul 2003 22:28:30 -0000 2.9 +++ dialog.h 26 Jul 2003 15:27:36 -0000 @@ -22,9 +22,6 @@ /* global instance for the application; set in main.cc */ extern HINSTANCE hinstance; -/* used by main.cc to select the next do_* function */ -extern int next_dialog; - /* either "nothing to do" or "setup complete" or something like that */ extern int exit_msg; @@ -33,15 +30,12 @@ extern int exit_msg; /* prototypes for all the do_* functions (most called by main.cc) */ D (do_download); -D (do_fromcwd); +bool do_fromcwd(HINSTANCE _h, HWND owner); D (do_ini); D (do_install); D (do_postinstall); #undef D - -/* end this dialog and select the next. Pass 0 to exit the program */ -#define NEXT(id) EndDialog((HWND)h, 0), next_dialog = id /* Get the value of an EditText control. Pass the previously stored value and it will free the memory if needed. */ Index: download.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/download.cc,v retrieving revision 2.37 diff -p -u -b -r2.37 download.cc --- download.cc 7 Apr 2003 12:46:55 -0000 2.37 +++ download.cc 26 Jul 2003 15:27:37 -0000 @@ -222,7 +222,7 @@ download_one (packagesource & pkgsource, } static void -do_download_thread (HINSTANCE h, HWND owner) +do_download_thread (HINSTANCE h, HWND owner, int *next_dialog) { int errors = 0; total_download_bytes = 0; @@ -306,7 +306,7 @@ do_download_thread (HINSTANCE h, HWND ow { if (yesno (owner, IDS_DOWNLOAD_INCOMPLETE) == IDYES) { - next_dialog = IDD_SITE; + *next_dialog = IDD_SITE; return; } } @@ -317,34 +317,42 @@ do_download_thread (HINSTANCE h, HWND ow exit_msg = IDS_DOWNLOAD_INCOMPLETE; else if (!unattended_mode) exit_msg = IDS_DOWNLOAD_COMPLETE; - next_dialog = 0; + *next_dialog = 0; } else - next_dialog = IDD_S_INSTALL; + *next_dialog = IDD_S_INSTALL; } +struct Context +{ + HINSTANCE hinst; + HWND hwnd; + int next_dialog; +}; + +static Context context; + static DWORD WINAPI do_download_reflector (void *p) { - HANDLE *context; - context = (HANDLE *) p; + Context *context; + context = (Context *) p; - do_download_thread ((HINSTANCE) context[0], (HWND) context[1]); + do_download_thread (context->hinst, context->hwnd, &context->next_dialog); // Tell the progress page that we're done downloading - Progress.PostMessage (WM_APP_DOWNLOAD_THREAD_COMPLETE, 0, next_dialog); + Progress.PostMessage (WM_APP_DOWNLOAD_THREAD_COMPLETE, 0, context->next_dialog); ExitThread(0); } -static HANDLE context[2]; - void do_download (HINSTANCE h, HWND owner) { - context[0] = h; - context[1] = owner; + context.hinst = h; + context.hwnd = owner; + context.next_dialog = 0; DWORD threadID; - CreateThread (NULL, 0, do_download_reflector, context, 0, &threadID); + CreateThread (NULL, 0, do_download_reflector, &context, 0, &threadID); } Index: fromcwd.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/fromcwd.cc,v retrieving revision 2.27 diff -p -u -b -r2.27 fromcwd.cc --- fromcwd.cc 19 May 2002 12:54:16 -0000 2.27 +++ fromcwd.cc 26 Jul 2003 15:27:37 -0000 @@ -71,7 +71,7 @@ private: bool found; }; -void +bool do_fromcwd (HINSTANCE h, HWND owner) { // Assume we won't find the INI file. @@ -80,15 +80,12 @@ do_fromcwd (HINSTANCE h, HWND owner) if (found_ini) { // Found INI, load it. - next_dialog = IDD_S_LOAD_INI; - return; + return true; } - next_dialog = IDD_CHOOSE; - IniParseFeedback myFeedback; IniDBBuilderPackage myBuilder(myFeedback); ScanFindVisitor myVisitor (myBuilder); Find(".").accept(myVisitor); - return; + return false; } Index: ini.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/ini.cc,v retrieving revision 2.35 diff -p -u -b -r2.35 ini.cc --- ini.cc 5 Jul 2002 05:17:21 -0000 2.35 +++ ini.cc 26 Jul 2003 15:27:38 -0000 @@ -204,7 +204,7 @@ do_remote_ini (HWND owner) } static void -do_ini_thread (HINSTANCE h, HWND owner) +do_ini_thread (HINSTANCE h, HWND owner, int *next_dialog) { size_t ini_count = 0; if (source == IDC_SOURCE_CWD) @@ -214,7 +214,7 @@ do_ini_thread (HINSTANCE h, HWND owner) if (ini_count == 0) { - next_dialog = source == IDC_SOURCE_CWD ? IDD_S_FROM_CWD : IDD_SITE; + *next_dialog = source == IDC_SOURCE_CWD ? IDD_S_FROM_CWD : IDD_SITE; return; } @@ -266,33 +266,41 @@ do_ini_thread (HINSTANCE h, HWND owner) note (owner, IDS_OLD_SETUP_VERSION, version, setup_version.cstr_oneuse()); } - next_dialog = IDD_CHOOSE; + *next_dialog = IDD_CHOOSE; } +struct Context +{ + HINSTANCE hinst; + HWND hwnd; + int next_dialog; +}; + +static Context context; + static DWORD WINAPI do_ini_thread_reflector(void* p) { - HANDLE *context; - context = (HANDLE*)p; + Context *context; + context = (Context*)p; - do_ini_thread((HINSTANCE)context[0], (HWND)context[1]); + do_ini_thread(context->hinst, context->hwnd, &context->next_dialog); // Tell the progress page that we're done downloading - Progress.PostMessage(WM_APP_SETUP_INI_DOWNLOAD_COMPLETE, 0, next_dialog); + Progress.PostMessage(WM_APP_SETUP_INI_DOWNLOAD_COMPLETE, 0, context->next_dialog); ExitThread(0); } -static HANDLE context[2]; - void do_ini (HINSTANCE h, HWND owner) { - context[0] = h; - context[1] = owner; + context.hinst = h; + context.hwnd = owner; + context.next_dialog = 0; DWORD threadID; - CreateThread (NULL, 0, do_ini_thread_reflector, context, 0, &threadID); + CreateThread (NULL, 0, do_ini_thread_reflector, &context, 0, &threadID); } Index: localdir.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/localdir.cc,v retrieving revision 2.13 diff -p -u -b -r2.13 localdir.cc --- localdir.cc 26 Jul 2003 09:16:51 -0000 2.13 +++ localdir.cc 26 Jul 2003 15:27:38 -0000 @@ -198,13 +198,14 @@ LocalDirPage::OnNext () { if (source == IDC_SOURCE_CWD) { - do_fromcwd (GetInstance (), GetHWND ()); - if (next_dialog == IDD_S_LOAD_INI) + bool found_ini; + found_ini = do_fromcwd (GetInstance (), GetHWND ()); + if (found_ini) { Progress.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD); return IDD_INSTATUS; } - return next_dialog; + return IDD_CHOOSE; } } else Index: main.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/main.cc,v retrieving revision 2.28 diff -p -u -b -r2.28 main.cc --- main.cc 26 Jul 2003 09:01:35 -0000 2.28 +++ main.cc 26 Jul 2003 15:27:40 -0000 @@ -66,8 +66,6 @@ static const char *cvsid = #include "UserSettings.h" -int next_dialog; - HINSTANCE hinstance; static BoolOption UnattendedOption (false, 'q', "quiet-mode", "Unattended setup mode");