diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 264349bd17f50a7d898c7d8e86400d32e04a3de6..8c582da83ca4ef1e4befdcf8547d60ab4accb7db 100644 (file)
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include "path-prefix.h"
-
-
+#include <cstring>
#include <glib/gmem.h>
#include <gtk/gtkiconfactory.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkimage.h>
-
#include <gtkmm/image.h>
+#include "path-prefix.h"
#include "prefs-utils.h"
#include "inkscape.h"
#include "document.h"
static guchar *sp_icon_image_load(SPIcon *icon, gchar const *name);
-static int sp_icon_get_phys_size(int size);
-
static void sp_icon_overlay_pixels( guchar *px, int width, int height, int stride,
unsigned r, unsigned g, unsigned b );
}
-static int sp_icon_get_phys_size(int size)
+int sp_icon_get_phys_size(int size)
{
static bool init = false;
static int lastSys[Inkscape::ICON_SIZE_DECORATION + 1];
int const x1 = std::min(area->x + area->width, widget.allocation.x + padx + static_cast<int>(icon->psize) );
int const y1 = std::min(area->y + area->height, widget.allocation.y + pady + static_cast<int>(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);
+ }
}
}
static guchar *
-sp_icon_image_load_pixmap(gchar const *name, unsigned lsize, unsigned psize)
+sp_icon_image_load_pixmap(gchar const *name, unsigned /*lsize*/, unsigned psize)
{
gchar *path;
guchar *px;
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<NR::Rect> dbox = SP_ITEM(object)->getBounds(i2doc);
if ( SP_OBJECT_PARENT(object) == NULL )
{
}
/* 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;
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 );
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 );
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);
}
static guchar *load_svg_pixels(gchar const *name,
- unsigned lsize, unsigned psize)
+ unsigned /*lsize*/, unsigned psize)
{
SPDocument *doc = NULL;
NRArenaItem *root = NULL;
// 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 {
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) {
pendingRenders.push(preRenderItem(lsize, name));
}
-gboolean icon_prerender_task(gpointer data) {
+gboolean icon_prerender_task(gpointer /*data*/) {
if (!pendingRenders.empty()) {
preRenderItem single=pendingRenders.front();
pendingRenders.pop();