Bug 462928 - Copying a file after another copies the first file again
Summary: Copying a file after another copies the first file again
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 22.12.0
Platform: Compiled Sources Linux
: HI normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
: 463095 463351 463579 463672 463816 464235 465193 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-12-11 19:47 UTC by Yannick Roehlly
Modified: 2023-02-07 17:21 UTC (History)
16 users (show)

See Also:
Latest Commit:
Version Fixed In: Dolphin 22.12.1 and/or KF 5.102


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yannick Roehlly 2022-12-11 19:47:39 UTC
SUMMARY

If I copy two files, one after the other by dropping the files between two dolphin windows, when dropping the second file dolphin actually drops the first file and offers me to overwrite it. Note that that works if I'm using two tabs instead of two windows.

STEPS TO REPRODUCE
1.  Create two folders and open them in separate dolphin windows.
2.  In one folder. Create a 1.txt file with "one" inside. Create a 2.txt file with "two" inside.
3.  Copy 1.txt by drag and dropping the file to the window with the second folder.
4.  Copy 2.txt by drag and dropping the file.

OBSERVED RESULT

Dolphin says that 1.txt is already in the folder. If I accept the overwrite, the content of 1.txt is "one" so it's not 2.txt that have been copies with 1.txt name.

EXPECTED RESULT

Both file are copied.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version:  5.26.4
KDE Frameworks Version:  5.100.0
Qt Version:  5.15.6

ADDITIONAL INFORMATION

I tried with Konqueror and the copy works as expected.

Also note that I'm using a locally compile dolphin 22.12.0 on Debian unstable. Maybe the problem occurs because I'm not having other 22.12.0 libraries.
Comment 1 antonio 2022-12-12 06:58:15 UTC
I confirm this bug.

Operating System: Debian GNU/Linux
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.100.0
Qt Version: 5.15.6
Comment 2 antonio 2022-12-12 07:06:37 UTC
It seems to be a clipboard problem: only the first element is inserted in the clipboard, the next are ignored, so the problem occurs
Comment 3 Per Pomsel 2022-12-12 08:38:13 UTC
...same here on Gentoo and Arch.
Comment 4 Aurélien COUDERC 2022-12-12 10:51:36 UTC
The same bug was reported on Debian unstable since the 22.12.0 upload :

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1025943
Comment 5 Felix Ernst 2022-12-13 17:04:16 UTC
I couldn't reproduce this.
Would be interesting to know if https://invent.kde.org/system/dolphin/-/commit/8d7e600f63a1961294dfe2c278a710b4ce0716e9 might be the cause of this. That commit made it so Dolphin can copy files to sandboxed applications (flatpak, snap). For this to work, it had to change what is exported to the clipboard.
Comment 6 antonio 2022-12-13 18:32:11 UTC
(In reply to Felix Ernst from comment #5)
> I couldn't reproduce this.
> Would be interesting to know if
> https://invent.kde.org/system/dolphin/-/commit/
> 8d7e600f63a1961294dfe2c278a710b4ce0716e9 might be the cause of this. That
> commit made it so Dolphin can copy files to sandboxed applications (flatpak,
> snap). For this to work, it had to change what is exported to the clipboard.

I tried to recompile locally, revert this commit solve the problem.
Comment 7 antonio 2022-12-13 19:07:51 UTC
(In reply to antonio from comment #6)
> (In reply to Felix Ernst from comment #5)
> > I couldn't reproduce this.
> > Would be interesting to know if
> > https://invent.kde.org/system/dolphin/-/commit/
> > 8d7e600f63a1961294dfe2c278a710b4ce0716e9 might be the cause of this. That
> > commit made it so Dolphin can copy files to sandboxed applications (flatpak,
> > snap). For this to work, it had to change what is exported to the clipboard.
> 
> I tried to recompile locally, revert this commit solve the problem.

The following changes create the problem:
	src/kitemviews/kitemlistcontroller.cpp
	src/views/dolphinview.cpp -> create problem
	
This change instead does not seem to influence:
	src/panels/folders/treeviewcontextmenu.cpp -> no problem

---

I don't know the code, but if you recompile these changes, no problems occur (and maintain export):

src/views/dolphinview.cpp:
	void DolphinView::cutSelectedItemsToClipboard()
	{
		QMimeData* mimeData = selectionMimeData();
		KIO::setClipboardDataCut(mimeData, true);
-		KUrlMimeData::exportUrlsToPortal(mimeData);
		QApplication::clipboard()->setMimeData(mimeData);
+		QMimeData* mimeData2 = selectionMimeData();
+		KUrlMimeData::exportUrlsToPortal(mimeData2);
	}

	void DolphinView::copySelectedItemsToClipboard()
	{
		QMimeData *mimeData = selectionMimeData();
-		KUrlMimeData::exportUrlsToPortal(mimeData);
		QApplication::clipboard()->setMimeData(mimeData);
+		QMimeData* mimeData2 = selectionMimeData();
+		KUrlMimeData::exportUrlsToPortal(mimeData2);
	}

src/kitemviews/kitemlistcontroller.cpp:
-   KUrlMimeData::exportUrlsToPortal(data);
+   QMimeData *data2 = m_model->createMimeData(selectedItems);
+   KUrlMimeData::exportUrlsToPortal(data2);

if it can help...
Comment 8 Felix Ernst 2022-12-13 22:58:03 UTC
(In reply to antonio from comment #6)
> (In reply to Felix Ernst from comment #5)
> > I couldn't reproduce this.
> > Would be interesting to know if
> > https://invent.kde.org/system/dolphin/-/commit/
> > 8d7e600f63a1961294dfe2c278a710b4ce0716e9 might be the cause of this. That
> > commit made it so Dolphin can copy files to sandboxed applications (flatpak,
> > snap). For this to work, it had to change what is exported to the clipboard.
> 
> I tried to recompile locally, revert this commit solve the problem.

Thanks a lot for testing! This helps quite a bit!

(In reply to antonio from comment #7)
> I don't know the code, but if you recompile these changes, no problems occur
> (and maintain export):

Your changes are unfortunately functionally identical to a complete revert of 8d7e600f63a1961294dfe2c278a710b4ce0716e9. We need the same `data` object that was used in `exportUrlsToPortal()` to make its way to the clipboard, otherwise it has no effect and we lose the functionality of copy-pasting into sandboxed applications. Thanks for trying to fix it though!
Comment 9 Felix Ernst 2022-12-14 12:33:57 UTC
Git commit c8aed8ac81d9f7f3dc93a7570037041228a98bf4 by Felix Ernst.
Committed on 14/12/2022 at 12:33.
Pushed by felixernst into branch 'release/22.12'.

Revert "portalize drag urls"

This reverts commit 8d7e600f63a1961294dfe2c278a710b4ce0716e9.

While this revert unfortunately removes Dolphin's ability to copy to
sandboxed applications, the bugs being temporarily fixed by this seem
more important. See the bugs mentioned below for details.

Especially copy-pasting needs to work flawlessly for an application
like Dolphin. After the revert this will either work correctly or – in
the case of sandboxed applications – not at all.
Related: bug 457529

M  +1    -3    src/kitemviews/kitemlistcontroller.cpp
M  +0    -1    src/panels/folders/treeviewcontextmenu.cpp
M  +1    -4    src/views/dolphinview.cpp

https://invent.kde.org/system/dolphin/commit/c8aed8ac81d9f7f3dc93a7570037041228a98bf4
Comment 10 Felix Ernst 2022-12-14 12:37:07 UTC
With above commit, this will be fixed for Dolphin 22.12.1. I didn't revert on master so I hope we will be able to fix this bug in time for the Dolphin 23.04 release. This bug report will be kept open to track that.
Comment 11 Xavier Corredor Llano 2022-12-15 02:10:04 UTC
First of all, thanks for the quick fix of this bug. Today I almost lost a lot of documents due to this error while moving and overwriting some files in different folders, this bug could be terrible, KDE's users can easily lose their data with this bug, IMHO please consider releasing this patch asap in a new release. 

Thanks so much.
Comment 12 Ilya Bizyaev 2022-12-15 11:08:26 UTC
I think the actual fix is here?
https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/267
Comment 13 Felix Ernst 2022-12-17 14:47:08 UTC
*** Bug 463095 has been marked as a duplicate of this bug. ***
Comment 14 Felix Ernst 2022-12-20 14:59:21 UTC
This should be fixed in the yet-to-be-released KDE frameworks 5.102 now by Ilya's commit https://invent.kde.org/frameworks/kcoreaddons/-/commit/75241a0929fb9d648c72385471760cfc937ff226. Marking as resolved.
Comment 15 Felix Ernst 2022-12-30 13:56:14 UTC
*** Bug 463579 has been marked as a duplicate of this bug. ***
Comment 16 Felix Ernst 2022-12-30 14:04:13 UTC
*** Bug 463351 has been marked as a duplicate of this bug. ***
Comment 17 Antonio Rojas 2023-01-18 09:57:16 UTC
*** Bug 464235 has been marked as a duplicate of this bug. ***
Comment 18 Antonio Rojas 2023-01-18 09:57:54 UTC
*** Bug 463672 has been marked as a duplicate of this bug. ***
Comment 19 Antonio Rojas 2023-01-18 09:58:23 UTC
*** Bug 463816 has been marked as a duplicate of this bug. ***
Comment 20 Felix Ernst 2023-02-07 17:21:28 UTC
*** Bug 465193 has been marked as a duplicate of this bug. ***