Commit 56d31a38 authored by Jim Nelson's avatar Jim Nelson

Conversation images don't show w/ Vala 0.23.1: Closes bgno#721000

Vala 0.23.1 introduced a change to how array .length property is
evaluated when transferring ownership to a method.  See
bgno#721001 for more information.
parent 7c7c4fec
......@@ -747,7 +747,9 @@ public class ConversationViewer : Gtk.Box {
uint8[] image_data;
pixbuf.save_to_buffer(out image_data, "png", "compression", "5");
rotated_image = new Geary.Memory.ByteBuffer.take((owned) image_data, image_data.length);
// Save length before transferring ownership (which frees the array)
int image_length = image_data.length;
rotated_image = new Geary.Memory.ByteBuffer.take((owned) image_data, image_length);
}
} catch (Error err) {
debug("Unable to load and rotate image %s for display: %s", filename, err.message);
......
......@@ -210,8 +210,10 @@ public class ConversationWebView : WebKit.WebView {
if (icon_content == null || icon_content.length == 0)
return;
// Save length before transferring ownership (which frees the array)
int icon_length = icon_content.length;
Geary.Memory.ByteBuffer buffer = new Geary.Memory.ByteBuffer.take((owned) icon_content,
icon_content.length);
icon_length);
// Then set the source to a data url.
WebKit.DOM.HTMLImageElement img = Util.DOM.select(get_dom_document(), selector)
......@@ -254,8 +256,10 @@ public class ConversationWebView : WebKit.WebView {
}
// Then set the source to a data url.
// Save length before transferring ownership (which frees the array)
int content_length = content.length;
Geary.Memory.Buffer buffer = new Geary.Memory.ByteBuffer.take((owned) content,
content.length);
content_length);
img.set_attribute("src", assemble_data_uri(icon_mime_type, buffer));
} catch (Error error) {
warning("Failed to load image '%s': %s", filename, error.message);
......
......@@ -438,8 +438,9 @@ public bool dissasemble_data_uri(string uri, out Geary.Memory.Buffer? buffer) {
uint8[] bytes = Base64.decode((string) (((char *) uri) + start_index));
// transfer ownership of the byte array directly to the Buffer; this prevents an
// unnecessary copy
buffer = new Geary.Memory.ByteBuffer.take((owned) bytes, bytes.length);
// unnecessary copy ... save length before transferring ownership (which frees the array)
int bytes_length = bytes.length;
buffer = new Geary.Memory.ByteBuffer.take((owned) bytes, bytes_length);
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment