Bug 416989

Summary: Konqueror's terminal window does not start in current directory
Product: [Applications] dolphin Reporter: Jonathan Marten <jjm>
Component: generalAssignee: phd <phd>
Status: RESOLVED FIXED    
Severity: normal CC: elvis.angelaccio, kfm-devel, nate, phd
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Jonathan Marten 2020-01-31 15:52:32 UTC
SUMMARY

Yes, this bug is being initially reported for Dolphin, because even though the problem only shows up in Konqueror the bug seems to be either in the DolphinPart or KParts.

When using Konqueror's Tools - Open Terminal action (F4), the terminal shell should start in the directory shown in the file manager.  Since https://phabricator.kde.org/D26140 this is not the case, the terminal always starts in $HOME.

In DolphinPart::slotOpenTerminal() that change replaced the stat and local file conversion with KParts::ReadOnlyPart::localFilePath().  localFilePath() returns d->m_file, which is never set by any function that DolphinPart calls;  it remains as null and so the KToolInvocation::invokeTerminal() always starts in the home directory.

DolphinPart::openUrl() calls KParts::ReadOnlyPart::setUrl() with the comment "remember it at the KParts level", but KParts::ReadOnlyPart::setUrl() does not set d->m_file, only KParts::ReadOnlyPart::openUrl() does.

Possible solutions that I can think of would be either:

(a) Call KParts::ReadOnlyPart::openUrl() instead of setUrl() in DolphinPart::openUrl().
(b) Resolve the local directory in DolphinPart::openUrl(), as was removed by the diff, and pass that to KParts::ReadOnlyPart::setLocalFilePath().
(c) Additionally resolve the local path and set d->m_file in KParts::ReadOnlyPart::setUrl().

The Dolphin application does not use the DolphinPart, hence this problem does not show with its version of Open Terminal (Shift+F4).


STEPS TO REPRODUCE
1.  From the command linbe, run "konqueror /tmp".
2.  Observe that the specificied directory is shown.
3.  Press F4 and note that the terminal does not open in /tmp but $HOME.
Comment 1 phd 2020-02-03 23:29:52 UTC
Shouldn't this be fixed in KParts with ReadOnlyPart::setUrl() not only setting d->m_url but also updating d->m_file in a similar manner as the removed code did?
Comment 2 phd 2020-02-04 00:24:19 UTC
https://phabricator.kde.org/D27148
Comment 3 Elvis Angelaccio 2020-02-22 23:28:06 UTC
(In reply to Jonathan Marten from comment #0)
> SUMMARY
> 
> Yes, this bug is being initially reported for Dolphin, because even though
> the problem only shows up in Konqueror the bug seems to be either in the
> DolphinPart or KParts.
> 
> When using Konqueror's Tools - Open Terminal action (F4), the terminal shell
> should start in the directory shown in the file manager.  Since
> https://phabricator.kde.org/D26140 this is not the case, the terminal always
> starts in $HOME.
> 
> In DolphinPart::slotOpenTerminal() that change replaced the stat and local
> file conversion with KParts::ReadOnlyPart::localFilePath().  localFilePath()
> returns d->m_file, which is never set by any function that DolphinPart
> calls;  it remains as null and so the KToolInvocation::invokeTerminal()
> always starts in the home directory.
> 
> DolphinPart::openUrl() calls KParts::ReadOnlyPart::setUrl() with the comment
> "remember it at the KParts level", but KParts::ReadOnlyPart::setUrl() does
> not set d->m_file, only KParts::ReadOnlyPart::openUrl() does.
> 
> Possible solutions that I can think of would be either:
> 
> (a) Call KParts::ReadOnlyPart::openUrl() instead of setUrl() in
> DolphinPart::openUrl().

This looks like the simpler solution to me. Any volunteer?
Comment 4 phd 2020-03-02 18:46:46 UTC
https://phabricator.kde.org/D27790
Comment 5 Bug Janitor Service 2020-12-29 16:13:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/151
Comment 6 Elvis Angelaccio 2020-12-29 22:28:41 UTC
Fixed with 741072272f5d8b45228a3adc9ccb873abf78f891