# HG changeset patch # User Mike Ruprecht # Date 1537906796 18000 # Node ID 14861f3ffe0cf082eb4c75d9f0822f3d7377d360 # Parent 7888def494374683f3c77f22ab193cf656ddfd7b gtkwebview: Fix displaying image from memory When the web view was updated to support the newer PurpleImage, purple_image_get_path() only returned a value if it was created from a file path. Since then, PurpleImage has been changed to return a unique identifier, such as from a hash, if a filename is missing. This identifier isn't an absolute path. g_filename_to_uri() expects an absolute path and therefore, in the web view code, returns NULL. This handling code doesn't expect a NULL and fails to display the image. The PurpleImage API probably needs another improvement pass. This patch adds a comment to update the web view when this happens, although we may be using Talkatu by then. It also checks for the g_filename_to_uri() return value and handles NULLs. diff -r 7888def49437 -r 14861f3ffe0c pidgin/gtkwebview.c --- a/pidgin/gtkwebview.c Tue Sep 25 15:06:32 2018 -0500 +++ b/pidgin/gtkwebview.c Tue Sep 25 15:19:56 2018 -0500 @@ -194,9 +194,21 @@ return; if (img != NULL) { + /* At the time of this comment, purple_image_get_path() + * always returns something, whether it's the actual + * path or a unique identifier, such as derived from a + * hash. That API will probably be reviewed after which + * this code can probably be simplified. + */ + gchar *uri = NULL; + path = purple_image_get_path(img); + if (path) { - gchar *uri = g_filename_to_uri(path, NULL, NULL); + uri = g_filename_to_uri(path, NULL, NULL); + } + + if (uri != NULL) { webkit_network_request_set_uri(request, uri); g_free(uri); } else {