Bug 369523 - DolphinPart: Cannot paste without refreshing the destination tab/window
Summary: DolphinPart: Cannot paste without refreshing the destination tab/window
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 16.12.2
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-29 10:09 UTC by sebaro
Modified: 2016-12-06 07:01 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sebaro 2016-09-29 10:09:51 UTC
dolphin-16.08.1
konqueror (kde-baseapps-git)
Sabayon (Gentoo)

Ctrl+V doesn't work and right click menu "Paste One File/Folder" is disabled until I refresh the destination window.

Reproducible: Always

Steps to Reproduce:
1. Copy file
2. Open new tab/window
3. Ctrl+V, nothing happens
Comment 1 Jonathan Marten 2016-10-03 14:32:01 UTC
Happens for me too, seems to have started fairly recently.

To confirm, this is where Konqueror is used as a file manager which embeds a DolphinPart.  It also happens with the sequence of operations:

1.  Cut or copy a file within Konqueror
2.  Change to a new directory within the same Konqueror window.
3.  Context menu item shows the correct text ("Paste N files"), but is greyed out.
4.  Refresh the view, the item is now enabled and works correctly.

Not sure where the problem is, so leaving the product unchanged at the moment.
Comment 2 Jonathan Marten 2016-10-03 19:58:40 UTC
Note that Dolphin as a file manager doesn't have this problem.

What seems to be happening in Konqueror is that DolphinPart::updatePasteAction() is being called once when the directory being viewed changes, from KonqMainWindow::openView().  When this calls DolphinView::pasteInfo() to obtain the text and enable state of the action, its rootItem() - which is equivalent to the rootItem() of the KDirLister for the directory - is a null item which means that KIO::pasteActionText() returns the state as disabled.

In Dolphin the corresponding function, DolphinMainWindow::updatePasteAction(), is called twice.  The first is from DolphinView::setURL(), and this time the rootItem() is null as before and the action would be disabled.  However, DolphinMainWindow::updatePasteAction() is then called a second time from DolphinView::slotDirectoryLoadingCompleted(), by which time the rootItem() is not null and the action is enabled.

I've not yet been able to find a way to connect this second call back to Konqueror, without it having to have specific knowledge of and a dependency on the DolphinPart.  One solution that I have found is to check the up-to-date paste state, in KonqMainWindow::slotPopupMenu(), as the popup menu is about to be displayed.  This gives a correctly enabled and working paste action in all cases... on the popup menu alone, but not for the menu bar Edit menu.  That would also have to be done in a similar way.

Adding dfaure to CC of this bug, in case he may have any insights.
Comment 3 sebaro 2016-10-03 20:13:04 UTC
Yes, it happens in the same tab/window too also in kio slaves windows (fish).

It doesn't happen in Dolphin, probably a bug would have been already opened if it did.
Comment 4 Jonathan Marten 2016-11-18 18:24:27 UTC
Found an easier solution.  If anyone can compile from source, please test.
The fix is to Dolphin, even though the problem only affects Konqueror...

--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -78,6 +78,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
             this, &DolphinPart::slotErrorMessage);
 
     connect(m_view, &DolphinView::directoryLoadingCompleted, this, static_cast<void(DolphinPart::*)()>(&DolphinPart::completed));
+    connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinPart::updatePasteAction);
     connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinPart::updateProgress);
     connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
Comment 5 sebaro 2016-11-18 20:43:56 UTC
The patch works for me, dolphin & konqueror from git.
Comment 6 Jonathan Marten 2016-11-20 15:29:18 UTC
https://git.reviewboard.kde.org/r/129448/
Comment 7 Jonathan Marten 2016-12-06 07:01:01 UTC
Git commit 16db90c7938d09bfa8916afef8cce8dd258fa00d by Jonathan Marten.
Committed on 06/12/2016 at 06:59.
Pushed by marten into branch 'master'.

Dolphin Part: Update the paste action at the end of the listing

Fixes a problem with the paste action not being enabled, only seen in
Konqueror.
REVIEW:129448

M  +1    -0    src/dolphinpart.cpp

https://commits.kde.org/dolphin/16db90c7938d09bfa8916afef8cce8dd258fa00d