Skip to content

Commit

Permalink
plugin: fix user-dir open, show error message if webgui fails
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Mar 21, 2024
1 parent cf55a07 commit 89dc184
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/plugin/DesktopUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ class DesktopUI : public UI,
d_stderr("webview port is %d", kPortNumOffset + port * 3 + 2);
webview = addWebView(getWindow().getNativeWindowHandle(), getScaleFactor(), kPortNumOffset + port * 3 + 2);

if (webview == nullptr)
{
error = "Error: Failed to create web view";
#if defined(DISTRHO_OS_MAC)
// no path for failure on macOS
#elif defined(DISTRHO_OS_WINDOWS)
errorDetail = "Please install the Microsoft Edge WebView2 Runtime";
#else
errorDetail = "Could not initialize X11";
#endif
}

buttonOpenWebGui.show();
repaint();
}
Expand Down
7 changes: 5 additions & 2 deletions src/plugin/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,18 @@ void openWebGui(const uint port)
static void* _openUserFilesDir(void*)
{
#ifdef _WIN32
ShellExecuteW(NULL, L"explore", getDataDirW(), nullptr, nullptr, SW_SHOWDEFAULT);
wchar_t userFilesDir[MAX_PATH] = {};
std::wcsncpy(userFilesDir, getDataDirW(), MAX_PATH - 1);
std::wcsncat(userFilesDir, L"\\user-files", MAX_PATH - 1);
ShellExecuteW(NULL, L"explore", userFilesDir, nullptr, nullptr, SW_SHOWDEFAULT);
#else
#ifdef __APPLE__
String cmd("open \"");
#else
String cmd("xdg-open \"");
#endif
cmd += getDataDir();
cmd += "\"";
cmd += "/user-files\"";
std::system(cmd);
#endif

Expand Down

0 comments on commit 89dc184

Please sign in to comment.