Bug 237353

Summary: "open with..." uses wrong filename (filename + 1)
Product: [Unmaintained] ksnapshot Reporter: S. Burmeister <sven.burmeister>
Component: generalAssignee: Richard Moore <rich>
Status: RESOLVED DUPLICATE    
Severity: normal CC: amihere007, balazs, bugzilla, de.meyer.maarten, hr.denzler, jjm
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Patch to fix

Description S. Burmeister 2010-05-12 10:47:30 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

In openSUSE pressing "Print" opens ksnaphot which takes a screenshot. If one saves that screenshot as e.g. screenshot to some folder and uses "open with..." after that, the application is given the wrong filename, i.e. the filename that would be used for the next screenshot, in this case it would be screenshot1.
Comment 1 Hans-Rudi Denzler 2010-05-12 22:52:48 UTC
I think "open with" means create a /tmp/kde-user/file and open file in e.g. gimp to modify it. Then you can save it in /home/user/file. This command is not "connected" to "save". Clicking save... changes the name for the next screenshot in the title bar.
a.) screenshot -> save > screenshot > save
b.) screenshot -> open with... gimp > save as..., repeat b.)
Comment 2 S. Burmeister 2010-05-13 07:03:22 UTC
I just described the buggy behaviour. And of course they are "connected" as after I saved the image and did not take a new one "open with" must refer to what ksnapshot shows that instant which is what I saved.

Even if not, which would be a bug IMHO, ksnapshot uses a non-existent filename when opening the external app which most certainly is a bug in some technique used for that feature.
Comment 3 Hans-Rudi Denzler 2010-05-13 11:36:21 UTC
Open with is a "follow up" action of what you "see" in ksnapshot, not what is on the hard disk. If you want to open your saved file, you must use another app. Your "Open saved file with..." button would be located right of "Save as...", since it has another meaning. If you modify your saved file, what do you "Open with..." now ?
a) the modified file [you]
b) what you see in ksnapshot in the preview window [me]

The "non-existent filename" in the title bar is the filename in the /tmp folder or the proposed filename for the next "Save as..." if you want to have multiple copies/screenshots.

Different views -> different thoughts
Comment 4 S. Burmeister 2010-05-14 09:39:19 UTC
Sorry, but you are simply wrong. No matter what, open with... should open a file, be it the temp file or what I saved. Yet it does not, that's a bug.

It worked before, it stopped, it's a bug.
Comment 5 Hans-Rudi Denzler 2010-05-14 12:55:53 UTC
"What you see, is what you get". When you click "open with", the "internal snapshot" is saved to the /tmp/kde-user/ folder and that file as shown in the title bar is opened. There is no logic like:
"if there is a file saved within the last 20 secs but not modified, then do open that file instead of a copy of the "internal snapshot".

Why not satisfy your wish by first clicking "Open with" and then in the external app you can choose "Save as..." when you are happy with the result.
Choose "Save as..." in ksnapshot if no checking or modifying is necessary.

gimp: select -> copy -> insert as > new picture > save
Comment 6 S. Burmeister 2010-05-14 13:12:17 UTC
Please read before you write!

ksnaphot does _not_ open the tempfile it shows in its GUI. It does _not_ open _any_ file.
Comment 7 Hans-Rudi Denzler 2010-05-14 14:03:41 UTC
In openSUSE 11.2 it does. I have dolphin with /tmp/kde-hrd/ and ksnapshot open, and then I press in ksnapshot "Open with..." gwenview or gimp and whoop the file appears in dolphin and gwenview shows the snapshot. Maybe your system is different and then you may forget what I wrote, sorry.
"What I see, is what I get"
Comment 8 Hans-Rudi Denzler 2010-05-14 15:45:08 UTC
If you want evidence, you can use the "strace" command in konsole:
> strace -e open -o output ksnapshot
> kwrite output

open("/tmp/kde-hrd/Bug 237353 - 4.png", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 11
Comment 9 S. Burmeister 2010-05-15 08:26:17 UTC
Are you using the packages from unstable, i.e. kde trunk? This bug is not about KDE 4.3 or KDE 4.4 it's about KDE 4.5 revision 1123195 as you can see in the headers of my first comment.
Comment 10 Hans-Rudi Denzler 2010-05-15 11:45:50 UTC
http://download.opensuse.org/repositories/KDE:/KDE4:/Factory:/Desktop/openSUSE_11.2/
When I carefully try to read the Description of Bug 237353, and use the strace command in Comment #8 and then
> cat output|grep "Bug 23735"
open("/home/hrd/Dokumente/Bug 237353.png", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 14 -> "Save as..."
open("/tmp/kde-hrd/Bug 237354.png", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 14 -> "Open with..." gwenview

I get evidence of your Description.
Comment 11 Jonathan Marten 2010-05-21 14:00:14 UTC
Can confirm that the problem summarised in comment #6 still exists with current KDE trunk (as of r1122514).

Open KSnapshot with an empty ksnapshotrc file (i.e. no file name history).  An image will be captured and the window title says "snapshot1.png".

Click "Open With - Okular".  Okular reports "Could not open file:///home/user/snapshot1.png".  Not surprising, because it doesn't exist.

Click "Save As" then "Save" with the default name.  The file is created, and the window title changes to "snapshot2.png".

Click "Open With - Okular" again.  Okular reports "Could not open file:///home/user/snapshot2.png".

Now here's another twist.  Click "New Snapshot", the title now says "snapshot2.png [modified]".  Click "Open With - Okular" and the file is opened from /tmp/kde-user (no file of that name has been saved in the default save location, i.e. home directory).

Possible solution: the initial snapshot taken when ksnapshot starts should set the "[modified]" status, as this is true (the file does not exist on disc), so that "Open With" will use a temporary file.
Comment 12 Jonathan Marten 2010-05-21 14:44:33 UTC
Created attachment 43775 [details]
Patch to fix

Proposed patch to fix.

Set the initial snapshot state to "modified", clear this when the snapshot is saved as before.  Auto-increment the file name only when a new snapshot is taken, not when it is saved (whether under the default name or "as").

Tested following the above scenario, the title bar and modified state correctly reflect whether the file has been saved and its on-disc file name.  Open With works as expected whether the file has been saved or not.
Comment 13 Richard Moore 2010-05-21 14:52:27 UTC
Does this patch cause a problem if the snapshot is saved twice? It sounds like the filename wouldn't be increamented.
Comment 14 Jonathan Marten 2010-05-21 14:58:42 UTC
Regarding comment #13: yes, that is true.  But then that is the same as the behaviour of any other application (e.g. KWrite) - repeatedly saving the same file doesn't increment the file name.
Comment 15 Petr Zmek 2010-06-27 12:44:11 UTC
Hello, I'm not sure if my bug is related to this one, but I presume it is:

1. Initial state: in ksnapshotrc in [GENERAL] section there is line filename[$e]=file://$HOME/tmp/AAA/snapshot.png
2. 
- take a screenshot and save it with different name in different directory as $HOME/picture.png 
--> a new name of new created screenshot is suggested as picture1.png
--> the filename line in ksnapshotrc changes to filename[$e]=file://$HOME/picture1.png
3. after every "save as" operation the default directory changes to last saved one and the screenshot name changes to last saved one+1.

Is this correct behaviour? I think the filename line has to stay unchanged. Or is there any reason to dynamicly changed filename line? I understand the counting of names in case of multiples screenshots, but why to change the whole address?

KDE 4.5 RC1, Fedora12 x86_64, installed from kde-redhat-unstable repo.
Comment 16 Hans-Rudi Denzler 2010-08-12 16:35:14 UTC
(In reply to comment #1)
> I think "open with" means create a /tmp/kde-user/file and open file in e.g.
> gimp to modify it. Then you can save it in /home/user/file. This command is not
> "connected" to "save". Clicking save... changes the name for the next
> screenshot in the title bar.
> a.) screenshot > save > screenshot > save
> b.) screenshot > open with... gimp > save as..., repeat b.)

KDE 4.5.0 doesn't pass test case b.) anymore (Could not open file).
c.) screenshot > save > open with... doesn't work either (Could not open file).
Comment 17 Terényi, Balázs 2010-09-08 18:04:28 UTC
Same problem here with KDE 4.5.1 on OpenSuSE 11.3, testcase b.) doesn't work. It worked before with KDE 4.4.X
Comment 18 Christoph Feck 2010-12-31 16:52:05 UTC
*** Bug 261039 has been marked as a duplicate of this bug. ***
Comment 19 S. Burmeister 2011-01-22 11:12:21 UTC
Still valid for KDE 4.6 RC2.
Comment 20 Maarten De Meyer 2013-05-07 17:52:12 UTC

*** This bug has been marked as a duplicate of bug 258431 ***