Bug 339009 - Inconsistent behavior in split view (browsing local HDD and FTP)
Summary: Inconsistent behavior in split view (browsing local HDD and FTP)
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: panels: terminal (show other bugs)
Version: 4.14.0
Platform: Arch Linux Linux
: NOR critical
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL: http://youtu.be/xji-3Bt7W_A
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-11 09:52 UTC by Alexander Nestorov
Modified: 2014-10-24 16:14 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Possible patch (work in progress) (3.27 KB, patch)
2014-10-19 22:09 UTC, Frank Reininghaus
Details
Corrected patch (3.28 KB, patch)
2014-10-19 22:13 UTC, Frank Reininghaus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Nestorov 2014-09-11 09:52:00 UTC
As you can see here ( http://youtu.be/xji-3Bt7W_A ) Dolphin's behavior is completely random/buggy when browsing a local folder and an FTP server at the same time, in split view mode.
This bug also happens sometimes while browsing local folder in both sides of the split view.

Reproducible: Always

Steps to Reproduce:
1. Open local folder in one of the panes in the split view
2. Open a remote (FTP) folder in the other pane in the split view
3. Double-click in a folder in the "local" view and then quickly click in the "remote" pane.

Actual Results:  
Both panes get assigned the same path (the local folder)

Expected Results:  
Dolphin should keep the local folder in the "local" pane and the remove FTP folder in the "remote" pane.

I'm leaving this as "Critical" because it made me delete several local folders/files (because I believed I was deleting remotely) until I realized the bug. This is serious and *should NOT* happen under any circumstances.
Comment 1 Arjun AK 2014-09-15 10:20:25 UTC

*** This bug has been marked as a duplicate of bug 305085 ***
Comment 2 Frank Reininghaus 2014-09-15 10:45:25 UTC
I'm not sure if this should be considered a duplicate of bug 305085. Bug 305085 is about the view URL being changed if a program in the terminal panel (such as git log) changes the current directory temporarily. This problem is probably unfixable in Dolphin - it has to be addressed in Konsole.

The present bug report is about something different:
1. The view URL changes, and a "cd" command is then sent to the terminal panel.
2. The Konsole part in the terminal panel periodically checks what the current directory is, and informs Dolphin's terminal panel about it.
3. If the URL of the view is different from the current directory that the Konsole part reports to the panel in step 2, the view URL is updated.

The problem is that the user may have invoked a manual URL change between steps 1 and 2 (e.g., by switching to another view). Another report, which is most likely about the very same problem, is bug 314038.

Ultimately, the root cause of this problem is that there is a delay of up to 1 second between the "cd" command that is sent to the terminal, and the signal that Konsole sends to report that the current directory has changed. I'm not sure if it's possible to do anything about that inside Konsole. Maybe there are ways to fix this inside Dolphin though - one could stop listening to Konsole's signal if a non-local URL is open in the view, for example. Getting this right without introducing new bugs or annoyances might not be easy though.

I'll reopen this report because it is IMHO different from bug 305085, as I said.
Comment 3 Arjun AK 2014-09-15 11:44:35 UTC
>one could stop listening to Konsole's signal if a non-local URL is open in the view

I too thought about that, but what if the directory was changed by the user?
Comment 4 Alexander Nestorov 2014-09-15 15:38:37 UTC
What about this:  

* Dolphin should IGNORE any changes that are made FROM konsole (git status, git log, etc...)
* Konsole should FOLLOW any changes that are made FROM Dolphin

That way the bug will be fixed, right?
Comment 5 Frank Reininghaus 2014-09-15 16:15:01 UTC
(In reply to Arjun Ak from comment #3)
> I too thought about that, but what if the directory was changed by the user?

You're right, this won't work. A more sophisticated solution is needed.

(In reply to Alexander Nestorov from comment #4)
> * Dolphin should IGNORE any changes that are made FROM konsole (git status,
> git log, etc...)

Yes, but it should follow directory changes that are made if the user types "cd somefolder" in the terminal panel. This was a rather frequently requested feature (see bug 156732), and the number of incoming bug reports about this issue was lower than the number of feature request reports, which is why I was always convinced that the feature should be kept, and proper solutions for the bugs have to be found (which is not really trivial, unfortunately).

I think we all agree that directory changes that are caused by "git log" or similar should be ignored, but  Unfortunately, Konsole does not tell us if a directory change was caused by a "cd" command or by "git log/status/etc.". However, as I said, this is actually unrelated to your bug report, which is due to the long delay between the "cd" command that Dolphin sends to Konsole and the signal received from Konsole, and Dolphin not noticing that the signal is the delayed result of its own "cd" command, and should thus be ignored.
Comment 6 Arjun AK 2014-09-15 16:37:19 UTC
>A more sophisticated solution is needed.

Is that even possible? What if the user uses a custom binary. Also different shells might have different ways to change directory. In fish, for instance, we can move into a directory by typing the directory's name.

One more thing that i noticed is that if you open the terminal while you are in a remote directory, you will be taken to the home directory.
Comment 7 Frank Reininghaus 2014-10-19 22:09:50 UTC
Created attachment 89202 [details]
Possible patch (work in progress)

This fixes both problems for me: the one from the original report and the "open the terminal in remote URL" issue. To fix the latter, I had to move the connect statement further down.

I'll test it some more and open a review request soon.
Comment 8 Frank Reininghaus 2014-10-19 22:13:26 UTC
Created attachment 89203 [details]
Corrected patch

Fixed a problem that I introduced when I edited the previous patch before uploading it.
Comment 9 Frank Reininghaus 2014-10-22 17:05:18 UTC
(In reply to Arjun AK from comment #6)
> One more thing that i noticed is that if you open the terminal while you are
> in a remote directory, you will be taken to the home directory.

I filed a new report about that (bug 340233) because it's not exactly the same issue that is described in this report.
Comment 10 Frank Reininghaus 2014-10-24 16:14:35 UTC
Git commit c9bf4752adcba7e88d11ae77479c618799b49341 by Frank Reininghaus.
Committed on 24/10/2014 at 16:13.
Pushed by freininghaus into branch 'master'.

Make the view/Terminal Panel synchronization less error-prone

The previous solution could cause problems if the user navigates to a
different URL in one view, and then activates another split view very
quickly: the new active view might be switched to the same URL as the
first view, which is unwanted.

To fix this problem, we record a history of "cd" commands that Dolphin
sends to the Terminal Panel in a queue. If a currentDirectoryChanged
signal is received, and the new terminal directory is "dir", this patch
does the following:

1.  If the queue is empty, change the view URL to "dir".
2.  Otherwise, take the queue's head, and check if it is equal to
    "dir". If that is the case, ignore the signal and return.
3.  Go back to step 1.

This ensures that every currentDirectoryChange signal that is caused by
a "cd" that was sent from Dolphin to the terminal is ignored.
Related: bug 314038
REVIEW: 120768

M  +18   -11   dolphin/src/panels/terminal/terminalpanel.cpp
M  +3    -0    dolphin/src/panels/terminal/terminalpanel.h

http://commits.kde.org/kde-baseapps/c9bf4752adcba7e88d11ae77479c618799b49341