SUMMARY In setup() method of a plugin called at Krita's startup: """ def setup(self): def windowCreated(): print('windowCreated!') print("Notifier active: ", Krita.instance().notifier().active()) Krita.instance().notifier().windowCreated.connect(windowCreated) """ In terminal we have: """ Notifier active: False windowCreated! """ That's not consistent: if notifier is not active, signal should not be emitted in window is created. An explicit call to """Krita.instance().notifier().setActive(False)""" fix the problem. STEPS TO REPRODUCE 1. Create a basic plugin 2. Edit setup() method to connect a signal for "windowCreated" 3. Execute Krita OBSERVED RESULT Even if notifier indicate it's not active, notifier signals are emitted EXPECTED RESULT The notifier should be properly initialized. There's 2 possibilities: 1) set the default value to True 2) set the default value to False and force signal to be blocked Personaly, I prefer the first solution because my plugins consider that by default notifier is active (and that's currently the case, signals are emitted by default) and if notifier is deactivated by default, this implies to update all plugins that use signals and consider that it's active by default.. ADDITIONAL INFORMATION Looking: https://invent.kde.org/graphics/krita/-/blob/master/libs/libkis/Notifier.cpp#L16 The variable is set to false by default """ struct Notifier::Private { Private() {} bool active {false}; }; """ But looking: https://invent.kde.org/graphics/krita/-/blob/master/libs/libkis/Notifier.cpp#L50 We can see that to activate/deactivate notifier signal, there's a call to 'blockSignals' """ void Notifier::setActive(bool value) { d->active = value; blockSignals(!value); } """ So whatever the solution is choosed (1 or 2), it might be better to force a call to blockSignals() when class is initialized, to be sure that activation status is consistent with defined value Grum999
Git commit 1fda121446e70ca0598065f2ccc3f87b9c966f50 by Halla Rempt. Committed on 03/10/2021 at 09:57. Pushed by rempt into branch 'krita/5.0'. Notifier: set the default value to "true" (cherry picked from commit 830d8e31eb53eafd164d13a6e7085d824005ce3d) M +3 -1 libs/libkis/Notifier.cpp https://invent.kde.org/graphics/krita/commit/1fda121446e70ca0598065f2ccc3f87b9c966f50
Git commit 83c00a8588d4323a1054cce312786263c2bd2a2e by Halla Rempt. Committed on 03/10/2021 at 09:57. Pushed by rempt into branch 'master'. Notifier: set the default value to "true" (cherry picked from commit 830d8e31eb53eafd164d13a6e7085d824005ce3d) M +3 -1 libs/libkis/Notifier.cpp https://invent.kde.org/graphics/krita/commit/83c00a8588d4323a1054cce312786263c2bd2a2e