Skip to content

Commit

Permalink
Merge branch 'fix-reset' into pb
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Feb 22, 2024
2 parents b9d5b58 + 691b6a1 commit f791739
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 12 additions & 2 deletions WeaselServer/WeaselServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,24 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lp
// command line option /q stops the running server
bool quit = !wcscmp(L"/q", lpstrCmdLine) || !wcscmp(L"/quit", lpstrCmdLine);
// restart if already running
if(quit)
{
weasel::Client client;
if (client.Connect()) // try to connect to running server
{
client.ShutdownServer();
if (quit)
return 0;
int retry = 0;
while (client.Connect() && retry < 10) {
client.ShutdownServer();
retry++;
Sleep(50);
}
if (retry >= 10)
return 0;
}
return 0;
else if (quit)
return 0;
}

bool check_updates = !wcscmp(L"/update", lpstrCmdLine);
Expand Down
2 changes: 0 additions & 2 deletions WeaselTSF/LanguageBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ void WeaselTSF::_HandleLangBarMenuSelect(UINT wID)
{
std::wstring dir(szValue);
std::thread th([dir]() {
ShellExecuteW(NULL, L"open", (dir + L"\\stop_service.bat").c_str(), NULL, dir.c_str(), SW_HIDE);
Sleep(100);
ShellExecuteW(NULL, L"open", (dir + L"\\start_service.bat").c_str(), NULL, dir.c_str(), SW_HIDE);
});
th.detach();
Expand Down

0 comments on commit f791739

Please sign in to comment.