Fix synchronization issues in the implementation of libkis
Open, HighPublic

Description

There are the following problems in the current Python API:

  1. some API calls are not synchronous, that is they are not completed by the time API call returns (see example fix here)
  2. some API calls do not initiate updates after they change the node (see example fix here)
  3. some API calls do not create undo command and basically ignore strokes and stuff that runs in the image atm (see example fix here)
  4. some API calls return invalid objects, because they cannot get correct info from an asynchronous object (see Node::mergeDown(), d->node does not belong to the image by the time the action completes, therefore d->node->prevSibling() is always null; please note that we cannot just call d->node->prevSibling() before starting the action, because 1) d->node->prevSibling() will also be removed from the image, 2) the result layer may be put in a different location in some cases (e.g. when some layers are locked or invisible))

Since we want our Python API be fully synchronous and behave "as if the user did it by hand", we need to look through every function of Python API and compare to how this action is executed in the normal Krita interface. These actions may either create a stroke, or pass a command to KisProcessingApplicator, or just call a member function, like in some of KisImage methods. After these calls the method should do waitForDone() to make it synchronous.

This change will solve the first three problems. Problem 4) is a bit more complicated and needs some fancy solution, like passing a shared state into a stroke/command.

Ideally, these API changes also needs some kind of unittesting, though I'm not sure how feasible it is.

UPD:

  1. There are needed Node::setDirty() and Node::setDirty(rect) calls. They also should be synchronous
dkazakov triaged this task as High priority.
dkazakov updated the task description. (Show Details)Sep 16 2020, 12:04 PM
dkazakov updated the task description. (Show Details)
rempt renamed this task from Fix synchronization issues in Python API to Fix synchronization issues in the implementation of libkis.Sep 16 2020, 12:51 PM