Faster
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@847 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ce50f46809
commit
53b82a6199
3 changed files with 48 additions and 71 deletions
|
@ -46,26 +46,26 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmd
|
|||
g_retcode = -1; // return code is always false unless set to true by GetExitCodeProcess
|
||||
g_warnings = FALSE;
|
||||
HWND hDialog = CreateDialog(g_hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
|
||||
if (!hDialog) {
|
||||
char buf [MAX_STRING];
|
||||
wsprintf(buf, "Error creating dialog box.\n\nError: %x", GetLastError ());
|
||||
MessageBox(0, buf, "Error", MB_ICONEXCLAMATION | MB_OK);
|
||||
return 1;
|
||||
}
|
||||
if (!hDialog) {
|
||||
char buf [MAX_STRING];
|
||||
wsprintf(buf, "Error creating dialog box.\n\nError: %x", GetLastError ());
|
||||
MessageBox(0, buf, "Error", MB_ICONEXCLAMATION | MB_OK);
|
||||
return 1;
|
||||
}
|
||||
haccel = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDK_ACCEL));
|
||||
MSG msg;
|
||||
int status;
|
||||
while ((status=GetMessage(&msg,0,0,0))!=0) {
|
||||
if (status==-1) return -1;
|
||||
MSG msg;
|
||||
int status;
|
||||
while ((status=GetMessage(&msg,0,0,0))!=0) {
|
||||
if (status==-1) return -1;
|
||||
if (!TranslateAccelerator(hDialog,haccel,&msg)) {
|
||||
if (!IsDialogMessage(hDialog,&msg)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitProcess(msg.wParam);
|
||||
return msg.wParam;
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||
|
@ -125,8 +125,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
EnumChildWindows(g_hwnd, DialogResize, (LPARAM)0);
|
||||
resizeRect = rSize;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
case WM_MAKENSIS_PROCESSCOMPLETE:
|
||||
{
|
||||
if (g_hThread) {
|
||||
|
@ -240,12 +240,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI MakeNSISProc(LPVOID p) {
|
||||
char buf[1024];
|
||||
STARTUPINFO si={sizeof(si),};
|
||||
SECURITY_ATTRIBUTES sa={sizeof(sa),};
|
||||
SECURITY_DESCRIPTOR sd={0,};
|
||||
|
@ -280,29 +279,27 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
|||
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||
return 1;
|
||||
}
|
||||
unsigned long exit=0,read,avail;
|
||||
my_memset(buf,0,sizeof(buf));
|
||||
while(1) {
|
||||
PeekNamedPipe(read_stdout,buf,sizeof(buf)-1,&read,&avail,NULL);
|
||||
if (read != 0) {
|
||||
my_memset(buf,0,sizeof(buf));
|
||||
if (avail > sizeof(buf)-1) {
|
||||
while (read >= sizeof(buf)-1) {
|
||||
ReadFile(read_stdout,buf,sizeof(buf)-1,&read,NULL);
|
||||
LogMessage(g_hwnd,buf);
|
||||
my_memset(buf,0,sizeof(buf));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ReadFile(read_stdout,buf,sizeof(buf),&read,NULL);
|
||||
LogMessage(g_hwnd,buf);
|
||||
}
|
||||
|
||||
char szBuf[1024];
|
||||
DWORD dwRead = 1;
|
||||
DWORD dwExit = !STILL_ACTIVE;
|
||||
|
||||
while (dwExit == STILL_ACTIVE || dwRead) {
|
||||
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
||||
if (dwRead) {
|
||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
||||
szBuf[dwRead] = 0;
|
||||
LogMessage(g_hwnd, szBuf);
|
||||
}
|
||||
else Sleep(TIMEOUT);
|
||||
GetExitCodeProcess(pi.hProcess, &dwExit);
|
||||
// Make sure we have no data before killing getting out of the loop
|
||||
if (dwExit != STILL_ACTIVE) {
|
||||
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
||||
}
|
||||
GetExitCodeProcess(pi.hProcess,&exit);
|
||||
if (exit != STILL_ACTIVE) break;
|
||||
Sleep(TIMEOUT);
|
||||
}
|
||||
g_retcode = exit;
|
||||
|
||||
g_retcode = dwExit;
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(newstdout);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#define REGKEY "Software\\NSIS"
|
||||
#define REGLOC "MakeNSISWPlacement"
|
||||
#define MAX_STRING 256
|
||||
#define TIMEOUT 800
|
||||
#define TIMEOUT 150
|
||||
#define MINWIDTH 350
|
||||
#define MINHEIGHT 180
|
||||
|
||||
|
|
|
@ -55,40 +55,12 @@ void ClearLog(HWND hwnd) {
|
|||
|
||||
char g_output_exe[1024];
|
||||
char g_input_script[1024];
|
||||
BOOL g_input_found;
|
||||
extern BOOL g_warnings;
|
||||
|
||||
void LogMessage(HWND hwnd,const char *str) {
|
||||
if (!str || !*str) return;
|
||||
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
|
||||
char *existing_text=(char*)GlobalAlloc(GPTR,len+lstrlen(str)+3);//3=\r\n\0
|
||||
if (!existing_text) return;
|
||||
existing_text[0]=0;
|
||||
GETTEXTEX gt={0};
|
||||
gt.cb = len;
|
||||
gt.codepage = CP_ACP;
|
||||
gt.flags = GT_DEFAULT;
|
||||
SendDlgItemMessage(hwnd,IDC_LOGWIN,EM_GETTEXTEX,(WPARAM)>,(LPARAM)existing_text);
|
||||
lstrcat(existing_text,str);
|
||||
if (!g_input_found) {
|
||||
char *p1=my_strstr(existing_text,"\r\nProcessing script file: \"");
|
||||
if (p1) {
|
||||
while (*p1++ != '"');
|
||||
char *p2=my_strstr(p1,"\r\n");
|
||||
lstrcpyn(g_input_script,p1,p2-p1);
|
||||
g_input_found=TRUE;
|
||||
}
|
||||
}
|
||||
if (my_strstr(existing_text," warning:")||my_strstr(existing_text," warnings:")) {
|
||||
g_warnings = TRUE;
|
||||
}
|
||||
SetDlgItemText(hwnd, IDC_LOGWIN, existing_text);
|
||||
SendDlgItemMessage(hwnd, IDC_LOGWIN,EM_SETSEL,lstrlen(existing_text),lstrlen(existing_text));
|
||||
SendDlgItemMessage(hwnd, IDC_LOGWIN,EM_SCROLLCARET,0,0);
|
||||
GlobalFree(existing_text);
|
||||
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (WPARAM)str);
|
||||
}
|
||||
|
||||
|
||||
void ErrorMessage(HWND hwnd,const char *str) {
|
||||
if (!str) return;
|
||||
char buf[1028];
|
||||
|
@ -99,7 +71,6 @@ void ErrorMessage(HWND hwnd,const char *str) {
|
|||
void DisableItems(HWND hwnd) {
|
||||
g_output_exe[0]=0;
|
||||
g_input_script[0]=0;
|
||||
g_input_found=FALSE;
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),0);
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_TEST),0);
|
||||
HMENU m = GetMenu(hwnd);
|
||||
|
@ -129,11 +100,20 @@ void EnableItems(HWND hwnd) {
|
|||
lstrcpy(g_output_exe,p2);
|
||||
}
|
||||
}
|
||||
p=my_strstr(existing_text,"\r\nProcessing script file: \"");
|
||||
if (p) {
|
||||
while (*p++ != '"');
|
||||
char *p2=my_strstr(p,"\r\n");
|
||||
lstrcpyn(g_input_script,p,p2-p);
|
||||
}
|
||||
if (my_strstr(existing_text, " warning:") || my_strstr(existing_text, " warnings:")) {
|
||||
g_warnings = TRUE;
|
||||
}
|
||||
|
||||
HMENU m = GetMenu(hwnd);
|
||||
if (g_output_exe[0]) {
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_TEST),1);
|
||||
EnableMenuItem(m,IDM_TEST,MF_ENABLED);
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_TEST),1);
|
||||
EnableMenuItem(m,IDM_TEST,MF_ENABLED);
|
||||
}
|
||||
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),1);
|
||||
EnableMenuItem(m,IDM_SAVE,MF_ENABLED);
|
||||
|
@ -183,7 +163,7 @@ void SaveWindowPos(HWND hwnd) {
|
|||
p.length = sizeof(p);
|
||||
GetWindowPlacement(hwnd, &p);
|
||||
if (RegCreateKey(REGSEC,REGKEY,&hKey) == ERROR_SUCCESS) {
|
||||
RegSetValueEx(hKey,REGLOC,0,REG_BINARY,(unsigned char*)&p,sizeof(p));
|
||||
RegSetValueEx(hKey,REGLOC,0,REG_BINARY,(unsigned char*)&p,sizeof(p));
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue