Skip to content

Commit

Permalink
Merge pull request #937 from eht16/win32_open_uri_error_handling
Browse files Browse the repository at this point in the history
Add error reporting for opening URIs on Windows
  • Loading branch information
eht16 committed Mar 12, 2016
2 parents fc811ec + 2f5eca2 commit 8254271
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/win32.c
Expand Up @@ -785,6 +785,7 @@ gint win32_check_write_permission(const gchar *dir)
/* Just a simple wrapper function to open a browser window */
void win32_open_browser(const gchar *uri)
{
gint ret;
if (strncmp(uri, "file://", 7) == 0)
{
uri += 7;
Expand All @@ -794,7 +795,14 @@ void win32_open_browser(const gchar *uri)
uri++;
}
}
ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL);
ret = (gint) ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL);
if (ret <= 32)
{
gchar *err = g_win32_error_message(GetLastError());
/* TODO add a GUI warning that opening an URI failed */
g_warning("ShellExecute failed opening \"%s\" (code %d): %s", uri, ret, err);
g_free(err);
}
}


Expand Down

0 comments on commit 8254271

Please sign in to comment.