kimoa / svg-edit

Automatically exported from code.google.com/p/svg-edit
MIT License
3 stars 0 forks source link

Patch for svgcanvas.js: Fix Mouse target NPE in select handler #861

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load the attached svg file into svg-edit
2. Double click the grouped two red boxes to enter group edit mode 
3. Leave group editing mode by double clicking outside the grouü
4. Single click the two red boxes group again to select it
5. Single click on the yellow rect (which is on another layer and thus cannot 
be selected) to unselect the red boxes group 

What is the expected output? What do you see instead?
The red boxes group should be unselected, now element in the drawing should be 
selected

Instead the group remains selected and the browser console shows an NPE 
exception in line 2370 of svg canvas: "mouse_target is null"

In what browser did you experience this problem? (ALL, Firefox, Opera, etc) all 
browsers

In what version of SVG-edit does the problem occur? (Latest trunk, 2.5.1,
etc) latest trunk

Please provide any additional information below.
The reason for this NPE exception is that the mouse target in step 5 is the 
yellow rect object, which is on another layer (and thus should not be 
selectable). But this rect is not an ancestor of the red boxes group. Thus the 
loop in svgcanvas, where we go up the dom tree until we find the current_group 
or current_layer only breaks with an NPE once parent_element of the document 
root node is null. The attached patch fixes this by breaking out of the loop as 
soon as we reach the svgroot element. 

Original issue reported on code.google.com by carsten.block@gmail.com on 27 Sep 2011 at 10:20

Attachments:

GoogleCodeExporter commented 9 years ago
I tried your patch and it does indeed prevent the JS console error.  However, 
with your patch I can do the following:

  a) load drawing.svg
  b) double-click the red rectangle to get into group-edit mode
  c) double-click the white area to leave exit group-edit mode
  d) double-click the yellow rectangle and you're now in group-edit mode with this:

    Ebene 2 > svg_editor > workarea > svgcanvas> svgroot

and I start seeing "slist is null" JS errors.

I agree with your analysis of the problem (the target being in another layer 
and not being able to get to the current_layer).  I just don't think the 
solution is as simple as this.

Original comment by codedr...@gmail.com on 1 Oct 2011 at 1:01