gnucash maint: Bug 747795 - Attached file not found.
John Ralls
jralls at code.gnucash.org
Sat Jul 11 14:28:07 EDT 2015
Updated via https://github.com/Gnucash/gnucash/commit/2137cb6d (commit)
from https://github.com/Gnucash/gnucash/commit/211b923c (commit)
commit 2137cb6d38aacfbe2d087563982d5a9613d324ee
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Jul 11 11:20:56 2015 -0700
Bug 747795 - Attached file not found.
MSWin only. ShellExecuteW("open") doesn't decode http escapes on file:
IRIs.
diff --git a/src/gnome-utils/gnc-gnome-utils.c b/src/gnome-utils/gnc-gnome-utils.c
index 02bed11..d0e5b9f 100644
--- a/src/gnome-utils/gnc-gnome-utils.c
+++ b/src/gnome-utils/gnc-gnome-utils.c
@@ -430,19 +430,31 @@ gnc_launch_assoc (const char *uri)
void
gnc_launch_assoc (const char *uri)
{
- wchar_t *winuri = (wchar_t *)g_utf8_to_utf16(uri, -1, NULL, NULL, NULL);
- wchar_t *wincmd = (wchar_t *)g_utf8_to_utf16("open", -1, NULL, NULL, NULL);
+ wchar_t *winuri = NULL;
+ /* ShellExecuteW open doesn't decode http escapes if it's passed a
+ * file URI so we have to do it. */
+ if (strcmp (g_uri_parse_scheme(uri), "file") == 0)
+ {
+ gchar *filename = g_filename_from_uri (uri, NULL, NULL);
+ winuri = (wchar_t *)g_utf8_to_utf16(filename, -1, NULL, NULL, NULL);
+ }
+ else
+ winuri = (wchar_t *)g_utf8_to_utf16(uri, -1, NULL, NULL, NULL);
+
if (winuri)
{
- if ((INT_PTR)ShellExecuteW(NULL, wincmd, winuri, NULL, NULL, SW_SHOWNORMAL) <= 32)
- {
- const gchar *message =
- _("GnuCash could not find the associated file.");
- gnc_error_dialog(NULL, "%s", message);
- }
- g_free (winuri);
+ wchar_t *wincmd = (wchar_t *)g_utf8_to_utf16("open", -1,
+ NULL, NULL, NULL);
+ if ((INT_PTR)ShellExecuteW(NULL, wincmd, winuri,
+ NULL, NULL, SW_SHOWNORMAL) <= 32)
+ {
+ const gchar *message =
+ _("GnuCash could not find the associated file");
+ gnc_error_dialog(NULL, "%s: %s", message, uri);
+ }
+ g_free (wincmd);
+ g_free (winuri);
}
- g_free (wincmd);
}
#else
Summary of changes:
src/gnome-utils/gnc-gnome-utils.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
More information about the gnucash-changes
mailing list