Windows: Fix deleting tempfile for winsparkle dll.
Trying to delete the temp file for the winsparkle dll after unloading the dll would still produce an access denied error, presumably because for whatever reason not all resources used by the dll were freed. Instead of trying to immediately delete the file, start an asynchronous cmd.exe process to sleep for 2 seconds and delete the file. This gives the app time to exit, after which the file can be deleted. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
89d378eb71
commit
0e8e46f0b7
|
@ -1,5 +1,7 @@
|
|||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <wx/utils.h>
|
||||
#include "wxvbam.h"
|
||||
#include "winsparkle-wrapper.h"
|
||||
#include "wx/msw/private.h"
|
||||
|
@ -47,7 +49,17 @@ WinSparkleDllWrapper::~WinSparkleDllWrapper()
|
|||
{
|
||||
delete winsparkle_dll;
|
||||
|
||||
wxRemoveFile(temp_file_name);
|
||||
// Wait for the program to exit and release the DLL before deleting the temp file, otherwise access is denied.
|
||||
const auto shell_cmd = std::string("ping -n 3 127.0.0.1 > nul&set _file=") + temp_file_name + "&call del %^_file%";
|
||||
|
||||
const char* cmd[]{
|
||||
"cmd.exe",
|
||||
"/c",
|
||||
shell_cmd.c_str(),
|
||||
NULL
|
||||
};
|
||||
|
||||
wxExecute(cmd, wxEXEC_ASYNC | wxEXEC_HIDE_CONSOLE);
|
||||
}
|
||||
|
||||
void win_sparkle_init()
|
||||
|
|
Loading…
Reference in New Issue