summaryrefslogtreecommitdiffstats
path: root/src/helper/pixbuf-ops.cpp
diff options
context:
space:
mode:
authortheAdib <theAdib@users.sourceforge.net>2009-05-11 22:08:17 +0000
committertheAdib <theAdib@users.sourceforge.net>2009-05-11 22:08:17 +0000
commit8c9d50b74134cac4232a88cb198e957e82cb24c1 (patch)
treec063b9a71aef4d10b8aee441b33662d852a290e7 /src/helper/pixbuf-ops.cpp
parentGerman translation update by McBen (diff)
downloadinkscape-8c9d50b74134cac4232a88cb198e957e82cb24c1.tar.gz
inkscape-8c9d50b74134cac4232a88cb198e957e82cb24c1.zip
BUG: #273767: crash on ...; resolved crash on several pixbuf operations
(bzr r7863)
Diffstat (limited to 'src/helper/pixbuf-ops.cpp')
-rw-r--r--src/helper/pixbuf-ops.cpp58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp
index 49a8cc28c..c7984137a 100644
--- a/src/helper/pixbuf-ops.cpp
+++ b/src/helper/pixbuf-ops.cpp
@@ -99,6 +99,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/,
{
+ GdkPixbuf* pixbuf = NULL;
/* Create new arena for offscreen rendering*/
NRArena *arena = NRArena::create();
nr_arena_set_renderoffscreen(arena);
@@ -140,36 +141,45 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/,
nr_arena_item_invoke_update(root, &final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE);
- guchar *px = g_new(guchar, 4 * width * height);
+ guchar *px = g_try_new(guchar, 4L * width * height);
- NRPixBlock B;
- nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N,
- final_bbox.x0, final_bbox.y0, final_bbox.x1, final_bbox.y1,
- px, 4 * width, FALSE, FALSE );
-
- unsigned char dtc[4];
- dtc[0] = NR_RGBA32_R(bgcolor);
- dtc[1] = NR_RGBA32_G(bgcolor);
- dtc[2] = NR_RGBA32_B(bgcolor);
- dtc[3] = NR_RGBA32_A(bgcolor);
+ if(px != NULL)
+ {
- for (unsigned int fy = 0; fy < height; fy++) {
- guchar *p = NR_PIXBLOCK_PX(&B) + fy * B.rs;
- for (unsigned int fx = 0; fx < width; fx++) {
- for (int i = 0; i < 4; i++) {
- *p++ = dtc[i];
+ NRPixBlock B;
+ g_warning("sp_generate_internal_bitmap: nr_pixblock_setup_extern.");
+ nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N,
+ final_bbox.x0, final_bbox.y0, final_bbox.x1, final_bbox.y1,
+ px, 4 * width, FALSE, FALSE );
+
+ unsigned char dtc[4];
+ dtc[0] = NR_RGBA32_R(bgcolor);
+ dtc[1] = NR_RGBA32_G(bgcolor);
+ dtc[2] = NR_RGBA32_B(bgcolor);
+ dtc[3] = NR_RGBA32_A(bgcolor);
+
+ for (unsigned int fy = 0; fy < height; fy++) {
+ guchar *p = NR_PIXBLOCK_PX(&B) + fy * B.rs;
+ for (unsigned int fx = 0; fx < width; fx++) {
+ for (int i = 0; i < 4; i++) {
+ *p++ = dtc[i];
+ }
}
}
- }
-
- nr_arena_item_invoke_render(NULL, root, &final_bbox, &B, NR_ARENA_ITEM_RENDER_NO_CACHE );
+
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB,
- TRUE,
- 8, width, height, width * 4,
- (GdkPixbufDestroyNotify)g_free,
- NULL);
+ nr_arena_item_invoke_render(NULL, root, &final_bbox, &B, NR_ARENA_ITEM_RENDER_NO_CACHE );
+ pixbuf = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB,
+ TRUE,
+ 8, width, height, width * 4,
+ (GdkPixbufDestroyNotify)g_free,
+ NULL);
+ }
+ else
+ {
+ g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %ld.", 4L * width * height);
+ }
sp_item_invoke_hide (SP_ITEM(sp_document_root(doc)), dkey);
nr_object_unref((NRObject *) arena);