Opened 8 years ago

Last modified 4 years ago

#13036 new enhancement

More validation for commands — at Version 12

Reported by: michael2402 Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: gsoc-core command Cc: Don-vip, bastiK, stoecker

Description (last modified by michael2402)

Currently, the command class does only few validation of the layer the command works for.

I suggest:

  • Enforce that layer may not be null. Make command construction fail if it is.
  • Always set the layer/dataset the command is working on.
  • Check that all primitives of that command belong to the layer layer (for add/move/delete/... commands).
    • if plugins want to change this, we can provide them with the means to extend the commands. They have to take care of the problems that occur then, e.g. handle data integrity.

Change History (12)

comment:1 by Don-vip, 8 years ago

Milestone: 16.0716.08

comment:2 by Don-vip, 8 years ago

Milestone: 16.0816.09

comment:3 by Don-vip, 8 years ago

Milestone: 16.0916.10

comment:4 by simon04, 8 years ago

Milestone: 16.1016.11

Milestone renamed

comment:5 by Don-vip, 7 years ago

Milestone: 16.1116.12

Milestone renamed

comment:6 by Don-vip, 7 years ago

Milestone: 16.12

comment:7 by michael2402, 7 years ago

In 12348/josm:

See #13036: Add more consistency checks to move / delete command.

comment:8 by michael2402, 7 years ago

In 12350/josm:

See #13036: Add data set tests to SelectCommand

in reply to:  description comment:9 by Don-vip, 7 years ago

Replying to michael2402:

  • Enforce that layer may not be null. Make command construction fail if it is.

If I remember correctly I have put a great effort to make sure a null layer is allowed, in order to work only with a dataset. Plugins rely on it.

comment:10 by Don-vip, 7 years ago

Milestone: 17.06

If dataset is forced now, all command constructors must be checked/updated. I have fixed in r12386 the problem that caused opendata plugin unit test to fail, but I think all constructors from DeleteCommand that don't take a Layer or a DataSet as parameter will cause errors when executed.

in reply to:  10 comment:11 by michael2402, 7 years ago

Replying to Don-vip:

If dataset is forced now, all command constructors must be checked/updated. I have fixed in r12386 the problem that caused opendata plugin unit test to fail, but I think all constructors from DeleteCommand that don't take a Layer or a DataSet as parameter will cause errors when executed.

Not necessarily. All commands that modify the edit data set (the one while they are created) are fine. Undo/Redo respects the layer that was used during the command construction.

The problem with unit tests is that they do not correctly set the edit layer during the test - this is why they fail. If we get errors in plugins, the plugin is using commands to modify a layer that is not the edit layer.

... but I agree: We should try to always add dataset information to our utility functions - it will make them more universal and allow them to be used on a data set that is not in any layer. I fixed this for the right/left hand traffic computations.

Last edited 7 years ago by michael2402 (previous) (diff)

comment:12 by michael2402, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.