aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-10-04 22:07:27 +0200
committerThomas White <taw@bitwiz.org.uk>2011-10-04 22:07:27 +0200
commit71d3e037a6934fbb4b57aed30c77efcc1efff3b0 (patch)
tree462e50601db65b357eca2cb52524e08ed89f80e5 /src
parenta32c1aa48a60f0d20a2dc237508ec9c2b5dcd729 (diff)
Allow deselect_object() to delete empty objects safely
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.c3
-rw-r--r--src/presentation.h2
-rw-r--r--src/tool_select.c3
-rw-r--r--src/tool_text.c11
4 files changed, 10 insertions, 9 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index df9ce49..d115ec3 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -369,7 +369,8 @@ static gint set_tool_sig(GtkWidget *widget, GtkRadioAction *action,
struct presentation *p)
{
if ( p->editing_object != NULL ) {
- p->cur_tool->deselect(p->editing_object, p->cur_tool);
+ int d = p->cur_tool->deselect(p->editing_object, p->cur_tool);
+ if ( d ) p->editing_object = NULL;
}
switch ( gtk_radio_action_get_current_value(action) )
diff --git a/src/presentation.h b/src/presentation.h
index c90c30f..1c24f5d 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -55,7 +55,7 @@ struct toolinfo
void (*create_default)(struct presentation *p, struct style *sty,
struct toolinfo *tip);
void (*select)(struct object *o, struct toolinfo *tip);
- void (*deselect)(struct object *o, struct toolinfo *tip);
+ int (*deselect)(struct object *o, struct toolinfo *tip);
void (*drag_object)(struct toolinfo *tip, struct presentation *p,
struct object *o, double x, double y);
void (*draw_editing_overlay)(cairo_t *cr, struct object *o);
diff --git a/src/tool_select.c b/src/tool_select.c
index c1168df..269dfc7 100644
--- a/src/tool_select.c
+++ b/src/tool_select.c
@@ -81,9 +81,10 @@ static void select_object(struct object *o,struct toolinfo *tip)
}
-static void deselect_object(struct object *o,struct toolinfo *tip)
+static int deselect_object(struct object *o,struct toolinfo *tip)
{
/* Do nothing */
+ return 0;
}
diff --git a/src/tool_text.c b/src/tool_text.c
index d40100f..8866d61 100644
--- a/src/tool_text.c
+++ b/src/tool_text.c
@@ -179,11 +179,7 @@ static void update_text(struct text_object *o)
o->fontdesc = pango_font_description_from_string(o->base.style->font);
pango_layout_set_font_description(o->layout, o->fontdesc);
- if ( furniture ) {
- calculate_size_from_style(o, &eright, &ebottom, &mw, &mh);
- } else {
- pango_layout_set_alignment(o->layout, PANGO_ALIGN_LEFT);
- }
+ calculate_size_from_style(o, &eright, &ebottom, &mw, &mh);
pango_layout_get_extents(o->layout, NULL, &logical);
o->base.bb_width = logical.width / PANGO_SCALE;
@@ -451,11 +447,14 @@ static void select_object(struct object *o,struct toolinfo *tip)
}
-static void deselect_object(struct object *o,struct toolinfo *tip)
+static int deselect_object(struct object *o,struct toolinfo *tip)
{
if ( (o != NULL) && o->empty ) {
delete_object(o);
+ return 1;
}
+
+ return 0;
}