Bug 416202 - Unable to load file by starting Krita while running an instance in single application mode
Summary: Unable to load file by starting Krita while running an instance in single app...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-13 12:44 UTC by Nicholas LaPointe
Modified: 2020-01-15 09:43 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas LaPointe 2020-01-13 12:44:05 UTC
When the "Allow only one instance of Krita" option is set and an instance of Krita is already running, trying to load a document by the likes of "krita ./document.kra" will do nothing.
This seems to be a regression caused by the resolution of bug #415794.

The following patch fixes this by reintroducing a chunk that was removed in 4c715c4c9470b9a454413cd9002ace514abc7ee1.
I chose to submit this as bug rather than a patch because I have not properly tested if it will make bug #415794 happen again and I don't have a clear understanding of what this change does at the moment, but I can commit it if desired.

diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cpp
index 4d94ee428f..8b0bfc4676 100644
--- a/libs/ui/KisApplication.cpp
+++ b/libs/ui/KisApplication.cpp
@@ -696,6 +696,10 @@ void KisApplication::remoteArguments(QByteArray message, QObject *socket)
 
     // check if we have any mainwindow
     KisMainWindow *mw = qobject_cast<KisMainWindow*>(qApp->activeWindow());
+    if (!mw) {
+        mw = KisPart::instance()->mainWindows().first();
+    }
+
     if (!mw) {
         d->earlyRemoteArguments << message;
         return;
Comment 1 vanyossi 2020-01-13 15:59:53 UTC
I tried krita with "Allow only one instance of Krita" launching from terminal to open file and it worked flawlesly (macOS).

just for the record, adding your patch will cause krita to reintroduce bug 415794 (tested launching it like "./krita ~/anim_brush.kra & ./krita ~/anim_brush.kra"
Comment 2 Nicholas LaPointe 2020-01-14 04:33:12 UTC
I tested more carefully today, but still got the same result.

This time, I made two builds -- one at 4c715c4c9470b9a454413cd9002ace514abc7ee1 (fix for bug #415794) and one at b4c44d395a7debd33c4bc1d9de52dcd556980a9a (its parent commit). Other than disabling PyQt by editing a CMakeLists.txt file (I don't have the right version installed), they were clean builds. I also cleared the config between tests.

The second build (pre-fix) worked as expected, but the other one did not.

The krita/4.2 branch also has this issue for me (it has the #415794 fix in commit 8db82515ce132c1190597aae1aa1f80f841dd5af).

Version information in case it is relevant:
Krita
 Version: 4.3.0-prealpha (git 4c715c4)
 Languages: en_US, en
 Hidpi: true

Qt
  Version (compiled): 5.13.2
  Version (loaded): 5.13.2

OS Information
  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.15.0-74-generic
  Pretty Productname: Ubuntu 18.04.3 LTS
  Product Type: ubuntu
  Product Version: 18.04
Comment 3 Nicholas LaPointe 2020-01-14 05:06:57 UTC
Ah, this is probably an important finding:

If I let Krita fully load and then try to load a document by "krita ./document.kra", it won't load it.

However, if I don't have any instance of Krita running, and then I run "krita ./document.kra & krita ./document.kra & krita ./document.kra & krita ./document.kra", an instance of Krita will open with four documents.

I can load a document while the splash screen is up, but it seems like it stops working correctly once a main window exists.
Comment 4 Halla Rempt 2020-01-14 09:48:58 UTC
Git commit db5ee6cd2b3230870dff14d1337299b6fdac19be by Boudewijn Rempt.
Committed on 14/01/2020 at 08:56.
Pushed by rempt into branch 'master'.

Fix regression when opening a new image in an existing krita instance

Thanks to Nicholas LaPointe who found the regression.

A  +-    --    bla.png
M  +5    -0    libs/ui/KisApplication.cpp

https://invent.kde.org/kde/krita/commit/db5ee6cd2b3230870dff14d1337299b6fdac19be
Comment 5 Halla Rempt 2020-01-15 09:43:45 UTC
Git commit b12857f6997f938625161c6e04a3e9e3f10fc0f6 by Boudewijn Rempt.
Committed on 15/01/2020 at 09:42.
Pushed by rempt into branch 'master'.

Check whether there are any mainwindows before taking the first
Related: bug 415794

M  +1    -1    libs/ui/KisApplication.cpp

https://invent.kde.org/kde/krita/commit/b12857f6997f938625161c6e04a3e9e3f10fc0f6