- Make the Win32 call to "unzip" use a minimized window.
authoranng888
Thu, 06 Dec 2007 18:43:23 +0000
changeset 633dad2c8993342
parent 632 f4282e4db9f7
child 634 8d7a84789707
- Make the Win32 call to "unzip" use a minimized window.
- Clean up process and thread handles from "unzip".
file.cpp
     1.1 --- a/file.cpp	Thu Dec 06 18:30:29 2007 +0000
     1.2 +++ b/file.cpp	Thu Dec 06 18:43:23 2007 +0000
     1.3 @@ -354,6 +354,8 @@
     1.4      // Set up members of the STARTUPINFO structure.
     1.5      ::ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
     1.6      siStartInfo.cb = sizeof(STARTUPINFO);
     1.7 +    siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
     1.8 +    siStartInfo.wShowWindow = SW_MINIMIZE;
     1.9  
    1.10      // Create command line.
    1.11      QString argv("unzip -o ");
    1.12 @@ -362,26 +364,32 @@
    1.13      argv.append(QDir::convertSeparators(zipDir.path()));
    1.14  
    1.15      // Create the child process.
    1.16 -    if( !::CreateProcess(NULL, 
    1.17 -        (LPWSTR)argv.unicode(), // command line
    1.18 -        NULL, // process security attributes
    1.19 -        NULL, // primary thread security attributes
    1.20 -        TRUE, // handles are inherited
    1.21 -        0, // creation flags
    1.22 -        NULL, // use parent's environment
    1.23 -        NULL, // use parent's current directory
    1.24 -        &siStartInfo, // STARTUPINFO pointer
    1.25 -        &piProcInfo) ) // receives PROCESS_INFORMATION
    1.26 +    if (!::CreateProcess(NULL, 
    1.27 +                         (LPWSTR) argv.unicode(), // command line
    1.28 +                         NULL, // process security attributes
    1.29 +                         NULL, // primary thread security attributes
    1.30 +                         TRUE, // handles are inherited
    1.31 +                         0, // creation flags
    1.32 +                         NULL, // use parent's environment
    1.33 +                         NULL, // use parent's current directory
    1.34 +                         &siStartInfo, // STARTUPINFO pointer
    1.35 +                         &piProcInfo) ) // receives PROCESS_INFORMATION
    1.36      {
    1.37 +		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
    1.38 +                               QObject::tr("Couldn't start unzip to decompress data."));
    1.39          err = aborted;
    1.40      }
    1.41      else
    1.42      {
    1.43          // Wait for it to finish.
    1.44 -        ::WaitForSingleObject( piProcInfo.hProcess, 10000 );
    1.45 +        ::WaitForSingleObject( piProcInfo.hProcess, INFINITE );
    1.46 +
    1.47 +        // Clean up handles.
    1.48 +        CloseHandle(piProcInfo.hThread);
    1.49 +        CloseHandle(piProcInfo.hProcess);
    1.50      }
    1.51  #endif
    1.52 -	return err;	
    1.53 +	return err;
    1.54  }
    1.55  
    1.56  bool loadStringFromDisk (const QString &fname, QString &s)
    1.57 @@ -495,5 +503,3 @@
    1.58  		if (imageFilters.at(i)==filter) return imageTypes.at(i);
    1.59  	return QString();	
    1.60  }
    1.61 -
    1.62 -