Index: Source/exehead/fileform.h =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/exehead/fileform.h,v retrieving revision 1.79 diff -u -r1.79 fileform.h --- Source/exehead/fileform.h 18 Feb 2005 13:39:42 -0000 1.79 +++ Source/exehead/fileform.h 30 May 2005 22:21:43 -0000 @@ -504,6 +507,8 @@ extern HANDLE g_db_hFile; extern int g_quit_flag; +extern int g_cancel_flag; +extern int g_install_thread_running; BOOL NSISCALL ReadSelfFile(LPVOID lpBuffer, DWORD nNumberOfBytesToRead); DWORD NSISCALL SetSelfFilePointer(LONG lDistanceToMove); Index: Source/exehead/Ui.c =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/exehead/Ui.c,v retrieving revision 1.232 diff -u -r1.232 Ui.c --- Source/exehead/Ui.c 17 May 2005 19:52:44 -0000 1.232 +++ Source/exehead/Ui.c 31 May 2005 02:49:26 -0000 @@ -42,6 +42,10 @@ int dlg_offset; int ui_dlg_visible=0; // At start main window is not visible int g_quit_flag; // set when Quit has been called (meaning bail out ASAP) +int g_cancel_flag; // set when Cancel button clicked during install +int g_install_thread_running; // set when install_thread is running + +HANDLE install_thread_handle; #if NSIS_MAX_INST_TYPES > 32 || NSIS_MAX_INST_TYPES < 1 #error invalid value for NSIS_MAX_INST_TYPES @@ -630,12 +634,17 @@ } else { + if (g_install_thread_running) + g_cancel_flag = TRUE; + else + { #ifdef NSIS_SUPPORT_CODECALLBACKS - if (!ExecuteCallbackFunction(CB_ONUSERABORT)) + if (!ExecuteCallbackFunction(CB_ONUSERABORT)) #endif//NSIS_SUPPORT_CODECALLBACKS - { - m_retcode=1; - outernotify(NOTIFY_BYE_BYE); + { + m_retcode=1; + outernotify(NOTIFY_BYE_BYE); + } } } } @@ -1415,6 +1424,8 @@ } #endif + g_install_thread_running = TRUE; + while (m_inst_sec--) { #ifdef NSIS_CONFIG_COMPONENTPAGE @@ -1436,12 +1447,28 @@ #endif s++; } - NotifyCurWnd(WM_NOTIFY_INSTPROC_DONE); + + g_install_thread_running = FALSE; + + if (g_cancel_flag && !g_exec_flags.abort) + { + g_cancel_flag = FALSE; +#ifdef NSIS_SUPPORT_CODECALLBACKS + if (!ExecuteCallbackFunction(CB_ONUSERABORT)) +#endif//NSIS_SUPPORT_CODECALLBACKS + { + g_quit_flag++; + g_exec_flags.abort++; + } + } #if defined(NSIS_SUPPORT_ACTIVEXREG) || defined(NSIS_SUPPORT_CREATESHORTCUT) OleUninitialize(); #endif + if (m_curwnd) + PostMessage(m_curwnd, WM_NOTIFY_INSTPROC_DONE, 0, 0); + return g_exec_flags.abort; } @@ -1501,7 +1528,7 @@ } if (uMsg == WM_NOTIFY_START) { DWORD id; - CloseHandle(CreateThread(NULL,0,install_thread,GetUIItem(IDC_PROGRESS),0,&id)); + install_thread_handle = CreateThread(NULL,0,install_thread,GetUIItem(IDC_PROGRESS),0,&id); } if (uMsg == WM_COMMAND && LOWORD(wParam) == IDC_SHOWDETAILS) { @@ -1511,6 +1538,12 @@ } if (uMsg == WM_NOTIFY_INSTPROC_DONE) { + if (install_thread_handle != NULL) + { + WaitForSingleObject(install_thread_handle, INFINITE); + CloseHandle(install_thread_handle); + install_thread_handle = NULL; + } if (g_quit_flag) { m_retcode=2; Index: Source/exehead/exec.c =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/exehead/exec.c,v retrieving revision 1.158 diff -u -r1.158 exec.c --- Source/exehead/exec.c 8 Apr 2005 15:29:52 -0000 1.158 +++ Source/exehead/exec.c 30 May 2005 19:36:25 -0000 @@ -68,6 +68,18 @@ extern int progress_bar_pos, progress_bar_len; progress_bar_pos+=rv; SendMessage(hwndProgress,PBM_SETPOS,MulDiv(progress_bar_pos,30000,progress_bar_len+!progress_bar_len),0); + + if (g_install_thread_running && g_cancel_flag) + { + g_cancel_flag = FALSE; +#ifdef NSIS_SUPPORT_CODECALLBACKS + if (!ExecuteCallbackFunction(CB_ONUSERABORT)) +#endif//NSIS_SUPPORT_CODECALLBACKS + { + g_quit_flag++; + return(EXEC_ERROR); + } + } } } return 0;