Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah committed Nov 6, 2023
1 parent cb1460c commit 82f4f16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
20 changes: 14 additions & 6 deletions src/framework/platform/unixplatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,27 @@ ticks_t Platform::getFileModificationTime(std::string file)
return 0;
}

void Platform::openUrl(std::string url)
void Platform::openUrl(std::string url, bool now)
{
if(url.find("http://") == std::string::npos && url.find("https://") == std::string::npos)
url.insert(0, "http://");

const auto& action = [url] {
#if defined(__APPLE__)
system(stdext::format("open %s", url).c_str());
system(stdext::format("open %s", url).c_str());
#else
int systemRet = system(stdext::format("xdg-open %s", url).c_str());
if(systemRet == -1){
return;
}
int systemRet = system(stdext::format("xdg-open %s", url).c_str());
if(systemRet == -1){
return;
}
#endif
};

if (now) {
action();
} else {
g_dispatcher.scheduleEvent(action, 50);

Check failure on line 162 in src/framework/platform/unixplatform.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-release

‘g_dispatcher’ was not declared in this scope

Check failure on line 162 in src/framework/platform/unixplatform.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-debug

‘g_dispatcher’ was not declared in this scope

Check failure on line 162 in src/framework/platform/unixplatform.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-release

‘g_dispatcher’ was not declared in this scope

Check failure on line 162 in src/framework/platform/unixplatform.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

‘g_dispatcher’ was not declared in this scope
}
}

std::string Platform::getCPUName()
Expand Down
10 changes: 6 additions & 4 deletions src/framework/platform/win32platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ void Platform::openUrl(std::string url, bool now)
if (url.find("http://") == std::string::npos && url.find("https://") == std::string::npos)
url.insert(0, "http://");

if (now) {
const auto& action = [url] {
ShellExecuteW(nullptr, L"open", stdext::utf8_to_utf16(url).data(), nullptr, nullptr, SW_SHOWNORMAL);
};

if (now) {
action();
} else {
g_dispatcher.scheduleEvent([url] {
ShellExecuteW(NULL, L"open", stdext::utf8_to_utf16(url).c_str(), NULL, NULL, SW_SHOWNORMAL);
}, 50);
g_dispatcher.scheduleEvent(action, 50);
}
}

Expand Down

0 comments on commit 82f4f16

Please sign in to comment.