[GRASS-dev] [GRASS GIS] #2503: wxdigit: wrong undo & redo

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
The undo and redo buttons in the digitizer (accessed via the Map Display)
seem to work well for simple features, but as soon as I use tools like
split line or similar, the results of undo and redo become somewhat
arbitrary (at least to the innocent user).

See a [http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo.ogv screencast]
of the issue.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [ticket:2503 mlennert]:
> The undo and redo buttons in the digitizer (accessed via the Map
Display) seem to work well for simple features, but as soon as I use tools
like split line or similar, the results of undo and redo become somewhat
arbitrary (at least to the innocent user).

Please try r63265 (trunk) or r63266 (relbr70).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mlennert):

Replying to [comment:1 mmetz]:
> Replying to [ticket:2503 mlennert]:
> > The undo and redo buttons in the digitizer (accessed via the Map
Display) seem to work well for simple features, but as soon as I use tools
like split line or similar, the results of undo and redo become somewhat
arbitrary (at least to the innocent user).
>
> Please try r63265 (trunk) or r63266 (relbr70).

Much better, thanks !

There still is some confusion when one goes back one or two steps, then
digitizes something else. When you then undo and redo again, the stack
seems to be mixed between the different paths, sometimes leading to
objects left on screen even when going all the way back to the last
possible undo.

You can check a [http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo3.ogv
short example screencast] and a
[http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo2.ogv longer example
screencast].

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:2 mlennert]:
> Replying to [comment:1 mmetz]:
> > Replying to [ticket:2503 mlennert]:
> > > The undo and redo buttons in the digitizer (accessed via the Map
Display) seem to work well for simple features, but as soon as I use tools
like split line or similar, the results of undo and redo become somewhat
arbitrary (at least to the innocent user).
> >
> > Please try r63265 (trunk) or r63266 (relbr70).
>
> Much better, thanks !
>
> There still is some confusion when one goes back one or two steps, then
digitizes something else.

The question is what should happen with the available redo steps if
digitize something new after some undo steps. Eliminate the redo steps or
insert the new changeset before the first redo step? This is handled by
the wx digitizer, not the vector lib.

> When you then undo and redo again, the stack seems to be mixed between
the different paths, sometimes leading to objects left on screen even when
going all the way back to the last possible undo.

It seems that a new changeset is appended after the last redo step if
available, leading to a mix-up.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mlennert):

Replying to [comment:3 mmetz]:
> Replying to [comment:2 mlennert]:
> > Replying to [comment:1 mmetz]:
> > > Replying to [ticket:2503 mlennert]:
> > > > The undo and redo buttons in the digitizer (accessed via the Map
Display) seem to work well for simple features, but as soon as I use tools
like split line or similar, the results of undo and redo become somewhat
arbitrary (at least to the innocent user).
> > >
> > > Please try r63265 (trunk) or r63266 (relbr70).
> >
> > Much better, thanks !
> >
> > There still is some confusion when one goes back one or two steps,
then digitizes something else.
>
> The question is what should happen with the available redo steps if
digitize something new after some undo steps. Eliminate the redo steps or
insert the new changeset before the first redo step? This is handled by
the wx digitizer, not the vector lib.

I've tried three different programs (LibreOffice Writer, Inkscape and
GIMP) and all discard these redo steps,i.e. when you do A, then B, then
undo B, then do C, you cannot find B again.

This seems to be the most intuitive behaviour to me.

>
> > When you then undo and redo again, the stack seems to be mixed between
the different paths, sometimes leading to objects left on screen even when
going all the way back to the last possible undo.
>
> It seems that a new changeset is appended after the last redo step if
available, leading to a mix-up.
>

Yes.

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:4 mlennert]:
> Replying to [comment:3 mmetz]:
> > Replying to [comment:2 mlennert]:
> > >
> > > There still is some confusion when one goes back one or two steps,
then digitizes something else.
> >
> > The question is what should happen with the available redo steps if
digitize something new after some undo steps. Eliminate the redo steps or
insert the new changeset before the first redo step? This is handled by
the wx digitizer, not the vector lib.
>
> I've tried three different programs (LibreOffice Writer, Inkscape and
GIMP) and all discard these redo steps,i.e. when you do A, then B, then
undo B, then do C, you cannot find B again.
>
> This seems to be the most intuitive behaviour to me.

OK.
>
> >
> > > When you then undo and redo again, the stack seems to be mixed
between the different paths, sometimes leading to objects left on screen
even when going all the way back to the last possible undo.
> >
> > It seems that a new changeset is appended after the last redo step if
available, leading to a mix-up.
> >
>
> Yes.

Fixed in trunk r63341, please test.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mlennert):

Replying to [comment:5 mmetz]:
> Replying to [comment:4 mlennert]:
> > Replying to [comment:3 mmetz]:
> > > Replying to [comment:2 mlennert]:
> > > >
> > > > There still is some confusion when one goes back one or two steps,
then digitizes something else.
> > >
> > > The question is what should happen with the available redo steps if
digitize something new after some undo steps. Eliminate the redo steps or
insert the new changeset before the first redo step? This is handled by
the wx digitizer, not the vector lib.
> >
> > I've tried three different programs (LibreOffice Writer, Inkscape and
GIMP) and all discard these redo steps,i.e. when you do A, then B, then
undo B, then do C, you cannot find B again.
> >
> > This seems to be the most intuitive behaviour to me.
>
> OK.
> >
> > >
> > > > When you then undo and redo again, the stack seems to be mixed
between the different paths, sometimes leading to objects left on screen
even when going all the way back to the last possible undo.
> > >
> > > It seems that a new changeset is appended after the last redo step
if available, leading to a mix-up.
> > >
> >
> > Yes.
>
> Fixed in trunk r63341, please test.

Much better !

There is still one issue I've come upon: when features are automatically
modified from the form they are digitized in because of overlaps, the
second original feature causing the overlap seems to be erased from the
undo stack, meaning that it remains, even if you undo all the way to
origin or if you close without saving.

To reproduce, digitize a line and then a second line that crosses that
line. The lines are correctly split at the intersection. If you then undo
the second line remains in its original (unsplit) form. The same is true
for two overlapping polygons or a line crossing a polygon.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:6 mlennert]:
>
> There is still one issue I've come upon: when features are automatically
modified from the form they are digitized in because of overlaps, the
second original feature causing the overlap seems to be erased from the
undo stack, meaning that it remains, even if you undo all the way to
origin or if you close without saving.
>
> To reproduce, digitize a line and then a second line that crosses that
line. The lines are correctly split at the intersection. If you then undo
the second line remains in its original (unsplit) form. The same is true
for two overlapping polygons or a line crossing a polygon.

The list of updated lines as returned by the vector lib was incomplete.
Fixed in r63349,50 (trunk, relbr70), please test.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mlennert):

Replying to [comment:7 mmetz]:
> Replying to [comment:6 mlennert]:
> >
> > There is still one issue I've come upon: when features are
automatically modified from the form they are digitized in because of
overlaps, the second original feature causing the overlap seems to be
erased from the undo stack, meaning that it remains, even if you undo all
the way to origin or if you close without saving.
> >
> > To reproduce, digitize a line and then a second line that crosses that
line. The lines are correctly split at the intersection. If you then undo
the second line remains in its original (unsplit) form. The same is true
for two overlapping polygons or a line crossing a polygon.
>
> The list of updated lines as returned by the vector lib was incomplete.
Fixed in r63349,50 (trunk, relbr70), please test.

Still not quite:
[http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo4.ogv\].

If you need more explanation, I can write some, but right now I have to
go.

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:8 mlennert]:
> Replying to [comment:7 mmetz]:
> > The list of updated lines as returned by the vector lib was
incomplete. Fixed in r63349,50 (trunk, relbr70), please test.
>
> Still not quite:
[http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo4.ogv\].
>
> If you need more explanation, I can write some, but right now I have to
go.

Got it. This bug (yet another one) should be fixed in r63364,5 (trunk
only).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mlennert):

Replying to [comment:9 mmetz]:
> Replying to [comment:8 mlennert]:
> > Replying to [comment:7 mmetz]:
> > > The list of updated lines as returned by the vector lib was
incomplete. Fixed in r63349,50 (trunk, relbr70), please test.
> >
> > Still not quite:
[http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo4.ogv\].
> >
> > If you need more explanation, I can write some, but right now I have
to go.
>
> Got it. This bug (yet another one) should be fixed in r63364,5 (trunk
only).

Wow, great detective work there ! As of now I haven't been able to find
any other bugs linked to undo/redo. This fix should be backported to
grass7release and then I think we can close this bug for now.

Thanks a lot for the fixes !

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: digitizer | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:10 mlennert]:
> Replying to [comment:9 mmetz]:
> > Replying to [comment:8 mlennert]:
> > > Replying to [comment:7 mmetz]:
> > > > The list of updated lines as returned by the vector lib was
incomplete. Fixed in r63349,50 (trunk, relbr70), please test.
> > >
> > > Still not quite:
[http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo4.ogv\].
> > >
> > > If you need more explanation, I can write some, but right now I have
to go.
> >
> > Got it. This bug (yet another one) should be fixed in r63364,5 (trunk
only).
>
> Wow, great detective work there ! As of now I haven't been able to find
any other bugs linked to undo/redo. This fix should be backported to
grass7release and then I think we can close this bug for now.

I do not fully understand 1) why the fix is needed, 2) why the fix is
working. The GRASS vector library usually employs Copy On Write (COW) when
a feature is modified. Sometimes a feature is modified in place,
overwriting the previous version. The digitizer's undo/redo mechanism
relies on COW, but the move tool seems to replace an older version of the
feature, thus undo/redo should not work with the move tool (and maybe
other tools, too).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
--------------------------+-------------------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: digitizer
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by mmetz):

  * status: new => closed
  * resolution: => fixed

Comment:

Replying to [comment:11 mmetz]:
> Replying to [comment:10 mlennert]:
> > Replying to [comment:9 mmetz]:
> > > Replying to [comment:8 mlennert]:
> > > > Replying to [comment:7 mmetz]:
> > > > > The list of updated lines as returned by the vector lib was
incomplete. Fixed in r63349,50 (trunk, relbr70), please test.
> > > >
> > > > Still not quite:
[http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo4.ogv\].
> > > >
> > > > If you need more explanation, I can write some, but right now I
have to go.
> > >
> > > Got it. This bug (yet another one) should be fixed in r63364,5
(trunk only).
> >
> > Wow, great detective work there ! As of now I haven't been able to
find any other bugs linked to undo/redo. This fix should be backported to
grass7release and then I think we can close this bug for now.
>
> I do not fully understand 1) why the fix is needed, 2) why the fix is
working.

The fix is working because V2_rewrite_line_nat() does not work as
expected, it does not rewrite, it always deletes the line and writes out a
new line (COW). All fixes related to this ticket have been backported to
relbr70 in r63397,8 after testing.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
--------------------------+-------------------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: digitizer
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------

Comment(by mlennert):

Replying to [comment:12 mmetz]:
> Replying to [comment:11 mmetz]:
> > Replying to [comment:10 mlennert]:
> > > Replying to [comment:9 mmetz]:
> > > > Replying to [comment:8 mlennert]:
> > > > > Replying to [comment:7 mmetz]:
> > > > > > The list of updated lines as returned by the vector lib was
incomplete. Fixed in r63349,50 (trunk, relbr70), please test.
> > > > >
> > > > > Still not quite:
[http://tomahawk.ulb.ac.be/moritz/wxdigit_undo_redo4.ogv\].
> > > > >
> > > > > If you need more explanation, I can write some, but right now I
have to go.
> > > >
> > > > Got it. This bug (yet another one) should be fixed in r63364,5
(trunk only).
> > >
> > > Wow, great detective work there ! As of now I haven't been able to
find any other bugs linked to undo/redo. This fix should be backported to
grass7release and then I think we can close this bug for now.
> >
> > I do not fully understand 1) why the fix is needed, 2) why the fix is
working.
>
> The fix is working because V2_rewrite_line_nat() does not work as
expected, it does not rewrite, it always deletes the line and writes out a
new line (COW). All fixes related to this ticket have been backported to
relbr70 in r63397,8 after testing.

You just signficantly improved the use of the digitizer, thanks a lot !

Just one question concerning r63398: shouldn't the code just be deleted
instead of using 'if 0' ?

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
--------------------------+-------------------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: digitizer
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------

Comment(by mmetz):

Replying to [comment:13 mlennert]:
>
> Just one question concerning r63398: shouldn't the code just be deleted
instead of using 'if 0' ?

I am not sure if the new PostGIS interface needs this, Martin would know
more about this, therefore I deactivated the code instead of deleting the
code. The same applies to the list of updated nodes (not used by the
digitizer, but by the PostGIS functions in the vector lib, I think).

Markus

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
--------------------------+-------------------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: digitizer
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by martinl):

* cc: martinl (added)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:15&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
--------------------------+-------------------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: digitizer
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------

Comment(by mlennert):

Martin,

Any opinion on the question concerning the ifdef'ed out code ?

For the rest we can close this ticket.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:16&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
--------------------------+-------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: digitizer
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by mlennert):

Using current trunk, any redo operation in wxdigit makes the GUI crash.
Don't know if this is related to this ticket or whether I should open a
new one. Can anyone confirm the behaviour ?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:17&gt;
GRASS GIS <http://grass.osgeo.org>

#2503: wxdigit: wrong undo & redo
--------------------------+-------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: digitizer
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by annakrat):

Replying to [comment:17 mlennert]:
> Using current trunk, any redo operation in wxdigit makes the GUI crash.
Don't know if this is related to this ticket or whether I should open a
new one. Can anyone confirm the behaviour ?

Yes, confirmed here (I have Ubuntu).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2503#comment:18&gt;
GRASS GIS <http://grass.osgeo.org>