gEDA-dev: Fixes for [ geda-Bugs-1851403 ] Crash after adding component while in move mode

Peter Clifton pcjc2 at cam.ac.uk
Sat Dec 15 22:01:22 EST 2007


I've been debugging this, and there are a couple of fixes needed:

1. Bringing up the component selector during another action.

Crash:
  Move action has state in the complex_place buffer, which the
  component selector frees. It isn't owned by the complex_place
  list, and is still linked into the main object list.

Fix:

diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index c404790..94d2ac6 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -2251,6 +2251,7 @@ DEFINE_I_CALLBACK(add_component)
 
   exit_if_null(w_current);
 
+  o_redraw_cleanstates (w_current);
   x_compselect_open (w_current);
 
   i_update_middle_button(w_current,


BUT.. this got me thinking, the component selector is non-modal, and I
can quite happily start a move action whilst it is still open. If I go
back to the component selector and make a placement (without cancelling
the move), it will crash.

Fix:

diff --git a/gschem/src/x_compselect.c b/gschem/src/x_compselect.c
index f0f9b10..59bbc7d 100644
--- a/gschem/src/x_compselect.c
+++ b/gschem/src/x_compselect.c
@@ -149,10 +149,8 @@ x_compselect_callback_response (GtkDialog *dialog,
         o_glist_draw_xor(w_current, diff_x, diff_y,
                          toplevel->page_current->complex_place_list);
 
-        /* Free the complex place list and its contents */
-        s_delete_object_glist(toplevel,
-                              toplevel->page_current->complex_place_list);
-        toplevel->page_current->complex_place_list = NULL;
+        /* Cancel any action / place operation currently in progress */
+        o_redraw_cleanstates (w_current);
 
         if (symbol == NULL) {
           /* If there is no symbol selected, switch to SELECT mode */

This seems to work,
BUT.. reading o_redraw_cleanstates(), there is something I find
confusing. If the event state is:

COPY, ENDCOPY, MCOPY, ENDMCOPY, DRAWBUS, DRAWCOMP, DRAWNET, ENDARC,
ENDBOX, ENDCIRCLE, ENDCOMP, ENDLINE, ENDMOVE, ENDPASTE, ENDPIN,
ENDTEXT, GRIPS, MOVE, NETCONT, ZOOMBOXEND

Then the event_state is reset to "SELECT".

The remaining cases:

NONE, SELECT, DRAWLINE, DRAWBOX, DRAWCIRCLE, ZOOM, PAN, BUSCONT,
DRAWARC, DRAWPICTURE, DRAWPIN, DRAWTEXT, ENDMIRROR, ENDPICTURE,
ENDROTATEP, ENDROUTENET, MOUSEPAN, SBOX, STARTCOPY, STARTMCOPY,
STARTDRAWBUS, STARTDRAWNET, STARTMOVE, STARTPAN, STARTPASTE,
STARTROUTENET, STARTSELECT, TEXTENTRY, ZOOMBOXSTART

Don't actually alter the event_state.

I'm wondering if anyone knows if this is intentional? If it would always
reset to (say) SELECT, then we could cut out a state-assignment in
x_compselect_callback_response() for the case where no component is
found to place. (And perhaps one or two other places).

Are there any reasons for the current behaviour?

Are there any potential bugs in the current behaviour?

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



More information about the geda-dev mailing list