Bug 350850

Summary: Kmymoney does not open multiple files correctly
Product: [Applications] kmymoney Reporter: Mark Blakeney <mark.blakeney>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: normal CC: agander93
Priority: NOR    
Version: 4.7.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.0.1
Sentry Crash Report:

Description Mark Blakeney 2015-08-01 07:32:13 UTC
I open 3 kmy files in parallel frequently as they are distinct and unrelated financial entities. When I click to open the 2nd file, kmymoney pops up a prompt "Another instance of KMyMoney is already running. Do you want to quit?" I always select "Yes" and then it opens fine. This prompt is annoying, superflous, and inconsistent with all other apps. KMM should just open the 2nd file in a new window, or if that file is already open in an existing window then just switch focus to that existing window like all other apps do, e.g. word-processors, editors, terminals, etc. If that is difficult to do with the current implementation of KMM then at least fix it to only prompt to quit if an existing open file is attempted to be opened (i.e. never open the same file twice) but do open any other file without any prompt.

This bug is obvious and has existed for many years but has probably not been complained about because clearly most people only use one KMM file.

Reproducible: Always

Steps to Reproduce:
1. As above description.
2.
3.
Comment 1 allan 2015-08-01 10:00:15 UTC
 This prompt is
> annoying, superflous, and inconsistent with all other apps. KMM should just
> open the 2nd file in a new window, or if that file is already open in an
> existing window then just switch focus to that existing window like all
> other apps do, e.g. word-processors, editors, terminals, etc. 
>
<snip>

> This bug is obvious and has existed for many years but has probably not been
> complained about because clearly most people only use one KMM file.

I don't think would class KMyMoney together with all other KMM apps.  To me, it's data is
important.  I could imagine opening KMM, then getting called away, coming back and 
opening a second instance, and then wondering why some of my data has gone missing.

I suspect many other users would want to be warned of the potential danger, otherwise,
as you point out, someone already would have asked for a change.

If such a change were to be implemented,  I would hope it would optional.
Comment 2 Mark Blakeney 2015-08-01 12:54:20 UTC
The comment above shows my description is not clear. :(

Let's explicitly describe a normal application. If you open a.doc from the file manager then libreoffice opens that doc in a window. If you later open b.doc from the file manager then libreoffice immediately opens that doc in another window. Later you open a.doc again from the file manager (while libreoffice already has that a.doc open in an existing window but perhaps hidden, minimized, or forgotten about) then libreoffice just immediately brings the existing open a.doc window to the foreground. There is no question of corrupting the a.doc file or having "missing data" because the app never allows 2 open windows on the same file. This same logic applies to just about every common application and file type in all modern linux, windows, or mac desktops (e.g. for pdf files etc). Kmymoney should obviously do the same thing with kmm files.  Most users rarely use multiple kmm files in parallel and that is the only reason this long standing bug has never been addressed.
Comment 3 Mark Blakeney 2015-08-02 03:17:52 UTC
I just noticed that if you try to open a file twice (by clicking through that first prompt) then KMM outputs another prompt that the file is already open. So at the very least please completely delete that first prompt as it is pointless. Ideally however, please fix this issue as I suggest above.
Comment 4 Mark Blakeney 2015-08-31 01:29:40 UTC
It looks like my request here won't get any traction. So please change this bug request to just delete that first redundant prompt as per my post 1 above. That's it, a simple change which should take little time.

I don't care anymore about trying to raise any existing window as I can do that myself with a desktop file wrapper script calling wmctrl. If this bug gets fixed then I will post that script publicly as it works well with kmymoney.
Comment 5 allan 2015-08-31 11:34:24 UTC
On 31/08/15 02:29, Mark Blakeney wrote:
> https://bugs.kde.org/show_bug.cgi?id=350850
>
> --- Comment #4 from Mark Blakeney <mark.blakeney@bullet-systems.net> ---
> It looks like my request here won't get any traction. So please change this bug
> request to just delete that first redundant prompt as per my post 1 above.
> That's it, a simple change which should take little time.
>
> I don't care anymore about trying to raise any existing window as I can do that
> myself with a desktop file wrapper script calling wmctrl. If this bug gets
> fixed then I will post that script publicly as it works well with kmymoney.
>

Don't take the lack of activity as an indication of disinterest.  We 
have no paid support people - they have to earn their crust - so please 
don't expect immediate solutions, as they may not come.  Then, 
priorities have to be taken into account - food first, then a crash will 
beat a wish-list request.

If you can produce a patch, that would help.

Allan
Comment 6 Mark Blakeney 2018-02-09 05:14:19 UTC
I was hoping that kmymoney version 5 would address this issue (which I raised 2.5 years ago!) however I see that it has made the situation worse. The issue here still exists but now you can open the same file twice or more and kmymoney does not complain about it. Presumably you could edit the file in parallel and corrupt it?

Please see my comment #2 above. That is how normal apps behave for multiple files and is how KMM should behave also. I really think many users would be complaining about this if it were not the case that 99% of users maintain only 1 KMM file.
Comment 7 wojnilowicz 2018-03-04 13:26:35 UTC
Git commit 3fc2c1f422c6ea415bdbd65703a4835504ccb4c6 by Łukasz Wojniłowicz.
Committed on 04/03/2018 at 13:24.
Pushed by wojnilowicz into branch 'master'.

Register KMyMoney with process ID
FIXED-IN:5.0.1

M  +1    -1    kmymoney/kmymoney.cpp
M  +0    -3    kmymoney/main.cpp

https://commits.kde.org/kmymoney/3fc2c1f422c6ea415bdbd65703a4835504ccb4c6
Comment 8 Thomas Baumgart 2018-03-04 15:04:37 UTC
Git commit 8a79b26a253fdd9a7e719a112e9610788aa9ebff by Thomas Baumgart.
Committed on 04/03/2018 at 15:04.
Pushed by tbaumgart into branch '5.0'.

Register KMyMoney with process ID

FIXED-IN:5.0.1

(cherry picked from commit 3fc2c1f422c6ea415bdbd65703a4835504ccb4c6)

M  +1    -1    kmymoney/kmymoney.cpp
M  +0    -3    kmymoney/main.cpp

https://commits.kde.org/kmymoney/8a79b26a253fdd9a7e719a112e9610788aa9ebff
Comment 9 Mark Blakeney 2018-09-10 05:52:01 UTC
After raising this bug 3 years ago I wrote a small script to work around this problem and have used it ever since with KMM. If anybody else comes along looking for the same solution that I requested here (but was never addressed by the "fixes" above), then see https://github.com/bulletmark/raise-or-run.