summaryrefslogtreecommitdiffstats
path: root/src/widgets/icon.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2007-03-04 19:07:06 +0000
committermental <mental@users.sourceforge.net>2007-03-04 19:07:06 +0000
commit2bc71af7910026787436a5013454a58b6bb3ec93 (patch)
tree0e6a25a344bcaaf31bc4138d099ba03d65519d44 /src/widgets/icon.cpp
parentreturn plain rect for union in all situations where a plain rect is given (diff)
downloadinkscape-2bc71af7910026787436a5013454a58b6bb3ec93.tar.gz
inkscape-2bc71af7910026787436a5013454a58b6bb3ec93.zip
more NR::Maybe<NR::Rect> work
(bzr r2543)
Diffstat (limited to 'src/widgets/icon.cpp')
-rw-r--r--src/widgets/icon.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 85666f76c..9be74a556 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -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<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);
+ }
}
}
@@ -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)->getBounds(i2doc);
+ NR::Maybe<NR::Rect> 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);