Bug 435235 - When pasting file using Projects tool view, "File Already Exists" window cannot be interacted with
Summary: When pasting file using Projects tool view, "File Already Exists" window cann...
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: UI: general (show other bugs)
Version: 5.6.2
Platform: Debian testing Linux
: HI normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
: 450316 454430 457968 468455 473894 492628 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-04-01 20:29 UTC by Brendon Higgins
Modified: 2025-02-18 14:10 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Version of some packages on my system where the bug appears (10.31 KB, text/plain)
2021-04-10 10:53 UTC, Julien Bigot
Details
Reduced KDevelop code that triggers the bug (1.24 KB, patch)
2023-01-09 10:25 UTC, Igor Kushnir
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brendon Higgins 2021-04-01 20:29:00 UTC
Hi,

SUMMARY

STEPS TO REPRODUCE
1. Open a project
2. In the Projects tool view, right-click on any file, and Copy
3. Right click on the folder that contained that file, and Paste
4. A "File Already Exists" window appears. Try to use it at all, e.g. edit the file name

OBSERVED RESULT
You can't interact with the window contents at all - not even Cancel works. Nor can you get back to KDevelop main window. You have to click the "Stop" button in the Plasma notification to abort the paste operation (causing KDevelop to then show you a "Paste Failed" window).

EXPECTED RESULT
Editable fields, working buttons...

Best,
Brendon
Comment 1 Julien Bigot 2021-04-10 10:53:21 UTC
Created attachment 137468 [details]
Version of some packages on my system where the bug appears
Comment 2 Julien Bigot 2021-04-10 10:54:37 UTC
I can confirm the bug here on a debian/sid (see list of packages version in the file above). Please let me know any additional info I could provide to help you pinpoint the issue.

Best,
Julien
Comment 3 Igor Kushnir 2021-04-12 16:35:16 UTC
The same bug is present in recent KDevelop master built from sources on Manjaro stable, Xfce.
Qt Version: 5.15.2
Frameworks Version: 5.80.0
Windowing System: X11
Comment 4 Igor Kushnir 2022-02-18 16:08:31 UTC
*** Bug 450316 has been marked as a duplicate of this bug. ***
Comment 5 Igor Grkavac 2022-02-23 16:37:56 UTC
Hi all,

The issue is happening due to the blocking calls of KJobs exec() functions that are called every time a Cut/Copy/Paste function is called. 
The explanation for this behavior can be seen here:
https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/src/lib/jobs/kjob.h#L268

The complete solution would be to abandon synchronous calls and connect signals and slots that wait for the Paste process to finish.

I managed to create a working solution for Cut action just to confirm it is doable, however, there is still a lot of refactoring left as a lot of different parts must be changed (ProjectManagerViewPlugin, CutCopyPasteHelper, AbstractFileManagerPlugin, ...) so, if anyone starts working on this, they will probably have a lot of code to write/change.

I will continue on this work and if any maintainer confirms this is a good strategy I will create a PR when I'm done.

Kind regards,
Igor Grkavac
Comment 6 Igor Kushnir 2022-03-03 19:31:02 UTC
> I will continue on this work and if any maintainer confirms this is a good strategy I will create a PR when I'm done.

I don't know if this is a good idea. Other maintainers may not reply here for a very long time. Just go ahead and create a merge request. Eventually it will be reviewed and likely merged. Note that you can create a draft MR - this way your chances of getting early feedback would be somewhat higher than here.
Comment 7 Igor Kushnir 2022-05-26 11:35:32 UTC
*** Bug 454430 has been marked as a duplicate of this bug. ***
Comment 8 Igor Kushnir 2022-08-17 12:10:18 UTC
*** Bug 457968 has been marked as a duplicate of this bug. ***
Comment 9 Igor Kushnir 2023-01-09 10:25:41 UTC
Created attachment 155130 [details]
Reduced KDevelop code that triggers the bug
Comment 10 Igor Kushnir 2023-01-09 10:31:21 UTC
(In reply to Igor Grkavac from comment #5)
> The issue is happening due to the blocking calls of KJobs exec() functions
> that are called every time a Cut/Copy/Paste function is called. 
> The explanation for this behavior can be seen here:
> https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/src/lib/jobs/
> kjob.h#L268
> 
> The complete solution would be to abandon synchronous calls and connect
> signals and slots that wait for the Paste process to finish.
After triggering this bug and being forced to restart KDevelop again, I managed to reduce the code, which causes the bug, to a bare minimum. Attached the patch. "DONE:" is never printed as the bug is triggered; when I send SIGTERM to the kdevelop process, it eventually crashes, but still does not print "DONE:". I think this bug is in KIO, because the KIO::copy() documentation - https://api.kde.org/frameworks/kio/html/classKIO_1_1CopyJob.html, https://api.kde.org/frameworks/kio/html/namespaceKIO.html#a8e3118adc0bb43d03ad15d67bc3d335c - doesn't forbid calling KIO::CopyJob::exec(). Have you considered reporting the KIO bug upstream?
Comment 11 Igor Kushnir 2023-04-13 09:29:14 UTC
*** Bug 468455 has been marked as a duplicate of this bug. ***
Comment 12 Igor Kushnir 2023-08-22 13:48:47 UTC
(In reply to Igor Kushnir from comment #10)
> I think this bug is in KIO, because the KIO::copy() documentation -
> https://api.kde.org/frameworks/kio/html/classKIO_1_1CopyJob.html,
> https://api.kde.org/frameworks/kio/html/namespaceKIO.html#a8e3118adc0bb43d03ad15d67bc3d335c - doesn't forbid calling
> KIO::CopyJob::exec(). Have you considered reporting the KIO bug upstream?
KJob::isStartedWithExec() was introduced in https://commits.kde.org/kcoreaddons/afe26afee3dfaebdaedeebadb2e0c860c1893093 to warn about calling exec() on a KIO job. But the warning itself hasn't been implemented in KIO. In any case, the best possible likely outcome is that the job would fail semi-silently (with a qWarning) instead of freezing KDevelop. A similar bug in Kate that inspired KJob::isStartedWithExec() was fixed by not calling exec() in https://commits.kde.org/kate/ded94b65ff4fbba38f123a19bcd650e67de711ff. So I believe doing the same, i.e. abandoning synchronous calls, in KDevelop is the right solution. Unfortunately, this correct solution appears to be much harder to implement in KDevelop than in Kate, because the offending exec() calls are located inside deeply nested helper functions, such as KDevelop::copyUrl().
Comment 13 Igor Kushnir 2023-08-22 13:51:16 UTC
(In reply to Igor Grkavac from comment #5)
> The complete solution would be to abandon synchronous calls and connect
> signals and slots that wait for the Paste process to finish.
> 
> I managed to create a working solution for Cut action just to confirm it is
> doable, however, there is still a lot of refactoring left as a lot of
> different parts must be changed (ProjectManagerViewPlugin,
> CutCopyPasteHelper, AbstractFileManagerPlugin, ...) so, if anyone starts
> working on this, they will probably have a lot of code to write/change.
> 
> I will continue on this work and if any maintainer confirms this is a good
> strategy I will create a PR when I'm done.
I am prepared to review such a merge request.
Comment 14 Igor Kushnir 2023-08-30 11:56:34 UTC
*** Bug 473894 has been marked as a duplicate of this bug. ***
Comment 15 Igor Kushnir 2024-09-05 16:03:38 UTC
*** Bug 492628 has been marked as a duplicate of this bug. ***
Comment 16 Ian H 2025-02-18 14:10:20 UTC
fyi still an issue on the latest 6.2.250370