X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fwidgets%2Ficon.cpp;h=9be74a556f9151431dee10c24372351cd6702599;hb=6b99999ff1758859233965fde1870955bca942d7;hp=0fadffdc862218231329328adadc1323846dbe73;hpb=f903f7d86c33cbf4d57cb4052158d3452289b579;p=inkscape.git diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 0fadffdc8..9be74a556 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -273,7 +273,7 @@ sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name ) addPreRender( lsize, name ); GtkStockItem stock; - bool tryLoad = gtk_stock_lookup( name, &stock ); + gboolean tryLoad = gtk_stock_lookup( name, &stock ); if ( !tryLoad && fallback ) { tryLoad |= strncmp("gtk-", name, 4 ) == 0; } @@ -529,12 +529,17 @@ static void sp_icon_paint(SPIcon *icon, GdkRectangle const *area) int const x1 = std::min(area->x + area->width, widget.allocation.x + padx + static_cast(icon->psize) ); int const y1 = std::min(area->y + area->height, widget.allocation.y + pady + static_cast(icon->psize) ); - gdk_draw_pixbuf(GDK_DRAWABLE(widget.window), NULL, image, - x0 - widget.allocation.x - padx, - y0 - widget.allocation.y - pady, - x0, y0, - x1 - x0, y1 - y0, - GDK_RGB_DITHER_NORMAL, x0, y0); + int width = x1 - x0; + int height = y1 - y0; + // Limit drawing to when we actually have something. Avoids some crashes. + if ( (width > 0) && (height > 0) ) { + gdk_draw_pixbuf(GDK_DRAWABLE(widget.window), NULL, image, + x0 - widget.allocation.x - padx, + y0 - widget.allocation.y - pady, + x0, y0, + width, height, + GDK_RGB_DITHER_NORMAL, x0, y0); + } } } @@ -609,7 +614,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, if (object && SP_IS_ITEM(object)) { /* Find bbox in document */ NR::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); - NR::Rect dbox = SP_ITEM(object)->invokeBbox(i2doc); + NR::Maybe dbox = SP_ITEM(object)->getBounds(i2doc); if ( SP_OBJECT_PARENT(object) == NULL ) { @@ -618,7 +623,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, } /* This is in document coordinates, i.e. pixels */ - if (dbox.isEmpty() == false) { + if ( dbox && !dbox->isEmpty() ) { NRGC gc(NULL); /* Update to renderable state */ double sf = 1.0; @@ -631,10 +636,10 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, NR_ARENA_ITEM_STATE_NONE ); /* Item integer bbox in points */ NRRectL ibox; - ibox.x0 = (int) floor(sf * dbox.min()[NR::X] + 0.5); - ibox.y0 = (int) floor(sf * dbox.min()[NR::Y] + 0.5); - ibox.x1 = (int) floor(sf * dbox.max()[NR::X] + 0.5); - ibox.y1 = (int) floor(sf * dbox.max()[NR::Y] + 0.5); + ibox.x0 = (int) floor(sf * dbox->min()[NR::X] + 0.5); + ibox.y0 = (int) floor(sf * dbox->min()[NR::Y] + 0.5); + ibox.x1 = (int) floor(sf * dbox->max()[NR::X] + 0.5); + ibox.y1 = (int) floor(sf * dbox->max()[NR::Y] + 0.5); if ( dump ) { g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 ); @@ -663,10 +668,10 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); /* Item integer bbox in points */ - ibox.x0 = (int) floor(sf * dbox.min()[NR::X] + 0.5); - ibox.y0 = (int) floor(sf * dbox.min()[NR::Y] + 0.5); - ibox.x1 = (int) floor(sf * dbox.max()[NR::X] + 0.5); - ibox.y1 = (int) floor(sf * dbox.max()[NR::Y] + 0.5); + ibox.x0 = (int) floor(sf * dbox->min()[NR::X] + 0.5); + ibox.y0 = (int) floor(sf * dbox->min()[NR::Y] + 0.5); + ibox.x1 = (int) floor(sf * dbox->max()[NR::X] + 0.5); + ibox.y1 = (int) floor(sf * dbox->max()[NR::Y] + 0.5); if ( dump ) { g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 ); @@ -713,7 +718,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, px + 4 * psize * (ua.y0 - area.y0) + 4 * (ua.x0 - area.x0), 4 * psize, FALSE, FALSE ); - nr_arena_item_invoke_render( root, &ua, &B, + nr_arena_item_invoke_render(NULL, root, &ua, &B, NR_ARENA_ITEM_RENDER_NO_CACHE ); nr_pixblock_release(&B); @@ -833,8 +838,8 @@ static guchar *load_svg_pixels(gchar const *name, // returns true if icon needed preloading, false if nothing was done static bool prerender_icon(gchar const *name, unsigned lsize, unsigned psize) { - Glib::ustring key=icon_cache_key(name, lsize, psize); - guchar *px=get_cached_pixels(key); + Glib::ustring key = icon_cache_key(name, lsize, psize); + guchar *px = get_cached_pixels(key); if (px) { return false; } else { @@ -849,10 +854,10 @@ static bool prerender_icon(gchar const *name, unsigned lsize, unsigned psize) static guchar * sp_icon_image_load_svg(gchar const *name, unsigned lsize, unsigned psize) { - Glib::ustring key=icon_cache_key(name, lsize, psize); + Glib::ustring key = icon_cache_key(name, lsize, psize); // did we already load this icon at this scale/size? - guchar *px=get_cached_pixels(key); + guchar *px = get_cached_pixels(key); if (!px) { px = load_svg_pixels(name, lsize, psize); if (px) {