https://bugs.kde.org/show_bug.cgi?id=426701

Tymond <tamtamy.tym...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Latest Commit|https://invent.kde.org/grap |https://invent.kde.org/grap
                   |hics/krita/commit/44a0f2258 |hics/krita/commit/ec086e453
                   |fe301245bf979bf9df3c907c876 |78ec8bb5111d3bf564bb56f5489
                   |cf22                        |78b5

--- Comment #7 from Tymond <tamtamy.tym...@gmail.com> ---
Git commit ec086e45378ec8bb5111d3bf564bb56f548978b5 by Agata Cacko.
Committed on 16/10/2020 at 00:40.
Pushed by tymond into branch 'krita/4.3'.

Fix Comic Manager race when updating multiple files

Before this commit, in case of updating multiple files at once,
for example when copying files into the `pages` directory to
overwrite existing ones, the following would happen:

signal filechanged(file1) -> url = file1 -> wait 200ms ->
    slot updatefile (update `url` file) -> url = ""

signal filechanged(file2) -> url = file2 -> wait 200ms ->
    slot updatefile (update `url` file) -> url = ""

When you update both file1 and file2 at once, a race condition
would happen and the exact sequence on the timeline would look more like
this:

signal filechanged(file1) -> url = file1 -> signal filechanged(file2)
   -> url = file2 -> wait 200ms -> slot updatefile (update `url` file,
   which is now `file2`) -> url = "" -> slot updatefile (update `url`
   file, which is now... an empty string

Then the plugin would crash on `realpath()` because the url is empty
and there is no check for that.

This commit fixes the behaviour by keeping a list of files to update.
That way in the first phase when lots of `filechanged` signals arrive,
all files to update are saved into a list and then after 200ms popped
from the list and updated one by one.

The most elegant solution would be to have QTimer keep the url,
it would be also possible to make the updatefile slot just update all
files from the list and return if the list is empty, but it's not
necessary because the signals will eventually arrive in the correct
number.


(cherry picked from commit 44a0f2258fe301245bf979bf9df3c907c876cf22)

M  +36   -31  
plugins/python/comics_project_management_tools/comics_project_manager_docker.py

https://invent.kde.org/graphics/krita/commit/ec086e45378ec8bb5111d3bf564bb56f548978b5

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to