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
|
@ -245,7 +245,6 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI MakeNSISProc(LPVOID p) {
|
DWORD WINAPI MakeNSISProc(LPVOID p) {
|
||||||
char buf[1024];
|
|
||||||
STARTUPINFO si={sizeof(si),};
|
STARTUPINFO si={sizeof(si),};
|
||||||
SECURITY_ATTRIBUTES sa={sizeof(sa),};
|
SECURITY_ATTRIBUTES sa={sizeof(sa),};
|
||||||
SECURITY_DESCRIPTOR sd={0,};
|
SECURITY_DESCRIPTOR sd={0,};
|
||||||
|
@ -280,29 +279,27 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
||||||
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
unsigned long exit=0,read,avail;
|
|
||||||
my_memset(buf,0,sizeof(buf));
|
char szBuf[1024];
|
||||||
while(1) {
|
DWORD dwRead = 1;
|
||||||
PeekNamedPipe(read_stdout,buf,sizeof(buf)-1,&read,&avail,NULL);
|
DWORD dwExit = !STILL_ACTIVE;
|
||||||
if (read != 0) {
|
|
||||||
my_memset(buf,0,sizeof(buf));
|
while (dwExit == STILL_ACTIVE || dwRead) {
|
||||||
if (avail > sizeof(buf)-1) {
|
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
||||||
while (read >= sizeof(buf)-1) {
|
if (dwRead) {
|
||||||
ReadFile(read_stdout,buf,sizeof(buf)-1,&read,NULL);
|
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
||||||
LogMessage(g_hwnd,buf);
|
szBuf[dwRead] = 0;
|
||||||
my_memset(buf,0,sizeof(buf));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ReadFile(read_stdout,buf,sizeof(buf),&read,NULL);
|
g_retcode = dwExit;
|
||||||
LogMessage(g_hwnd,buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GetExitCodeProcess(pi.hProcess,&exit);
|
|
||||||
if (exit != STILL_ACTIVE) break;
|
|
||||||
Sleep(TIMEOUT);
|
|
||||||
}
|
|
||||||
g_retcode = exit;
|
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
CloseHandle(pi.hProcess);
|
CloseHandle(pi.hProcess);
|
||||||
CloseHandle(newstdout);
|
CloseHandle(newstdout);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#define REGKEY "Software\\NSIS"
|
#define REGKEY "Software\\NSIS"
|
||||||
#define REGLOC "MakeNSISWPlacement"
|
#define REGLOC "MakeNSISWPlacement"
|
||||||
#define MAX_STRING 256
|
#define MAX_STRING 256
|
||||||
#define TIMEOUT 800
|
#define TIMEOUT 150
|
||||||
#define MINWIDTH 350
|
#define MINWIDTH 350
|
||||||
#define MINHEIGHT 180
|
#define MINHEIGHT 180
|
||||||
|
|
||||||
|
|
|
@ -55,40 +55,12 @@ void ClearLog(HWND hwnd) {
|
||||||
|
|
||||||
char g_output_exe[1024];
|
char g_output_exe[1024];
|
||||||
char g_input_script[1024];
|
char g_input_script[1024];
|
||||||
BOOL g_input_found;
|
|
||||||
extern BOOL g_warnings;
|
extern BOOL g_warnings;
|
||||||
|
|
||||||
void LogMessage(HWND hwnd,const char *str) {
|
void LogMessage(HWND hwnd,const char *str) {
|
||||||
if (!str || !*str) return;
|
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (WPARAM)str);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ErrorMessage(HWND hwnd,const char *str) {
|
void ErrorMessage(HWND hwnd,const char *str) {
|
||||||
if (!str) return;
|
if (!str) return;
|
||||||
char buf[1028];
|
char buf[1028];
|
||||||
|
@ -99,7 +71,6 @@ void ErrorMessage(HWND hwnd,const char *str) {
|
||||||
void DisableItems(HWND hwnd) {
|
void DisableItems(HWND hwnd) {
|
||||||
g_output_exe[0]=0;
|
g_output_exe[0]=0;
|
||||||
g_input_script[0]=0;
|
g_input_script[0]=0;
|
||||||
g_input_found=FALSE;
|
|
||||||
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),0);
|
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),0);
|
||||||
EnableWindow(GetDlgItem(hwnd,IDC_TEST),0);
|
EnableWindow(GetDlgItem(hwnd,IDC_TEST),0);
|
||||||
HMENU m = GetMenu(hwnd);
|
HMENU m = GetMenu(hwnd);
|
||||||
|
@ -129,6 +100,15 @@ void EnableItems(HWND hwnd) {
|
||||||
lstrcpy(g_output_exe,p2);
|
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);
|
HMENU m = GetMenu(hwnd);
|
||||||
if (g_output_exe[0]) {
|
if (g_output_exe[0]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue