Diffusion Krita ac2868ad23b5

Fix bad weak pointer usage

Authored by gladhorn on Nov 7 2016, 11:28 PM.

Description

Fix bad weak pointer usage

The assumption is that weak pointers can become null at any point in
time. Only dereference after converting to a strong pointer.

Details

Committed
gladhornNov 7 2016, 11:42 PM
Parents
R37:fddc7d907878: Add toStrongRef to KisWeakPtr
Branches
Unknown
Tags
Unknown
Reverted By
R37:de3957a65b43: Partially revert "Fix bad weak pointer usage"

Hi, @gladhorn!

What do you think if we introduce the following rules:

  1. By default store a link to image or node as a strong pointer in your class.
  2. If there is a hazard of a circular dependency or the class is stored in undo or GUI docker, store the link as a weak shared pointer.
  3. Even if the class stores a weak pointer, methods should always return a strong pointer. Therefore, always convert a weak pointer into strong one before returning from a function.

What do you think about such rules? Do they look sane?

/libs/image/brushengine/kis_paintop_settings.cpp
80

I feel that it is better to use full class name here instead of auto. Our policy is not very strict about that:

auto is fine, when using in for loops. Don't go overboard using it in other places.

But I guess it is the case :)

/libs/image/kis_default_bounds.cpp
126

The same :)

/libs/image/kis_group_layer.cc
147

I think KisLayer::image() should return already converted KisImageSP. This is not a regression though, just a note.