Bug 344110 - new tab NOT uses the same working directory as current tab (when midnight-commander is running)
Summary: new tab NOT uses the same working directory as current tab (when midnight-com...
Status: RESOLVED UPSTREAM
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 2.14.2
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-13 11:27 UTC by zsovig
Modified: 2019-09-27 06:35 UTC (History)
5 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 zsovig 2015-02-13 11:27:41 UTC
KDE Version: 4.14.3

Reproducible: Always

Steps to Reproduce:
1. run konsole
2. run mc in konsole
3. navigate to a directory
4. open a new tab

Actual Results:  
The new tab opens in the user's home directory.

Expected Results:  
The new tab opens in the directory where the user navigated in mc.

I investigated the problem - I think.
At the moment I am using the following versions of konsole:
konsole-4.14.3-1.fc20.x86_64.rpm
konsole-part-4.14.3-1.fc20.x86_64.rpm

So I returned back to the last working previous version, which are:
konsole-4.14.2-1.fc20.x86_64.rpm
konsole-part-4.14.2-1.fc20.x86_64.rpm

And now everything works perfectly.
So I downloaded konsole-4.14.3 and konsole-4.14.2 from here (http://download.kde.org/stable/4.14.3/src/konsole-4.14.3.tar.xz)  and here (http://download.kde.org/stable/4.14.2/src/konsole-4.14.2.tar.xz)
I did a directory comparison in Meld, and I found some changes in src/Session.cpp

--- konsole-4.14.2/konsole-4.14.2/src/Session.cpp
+++ konsole-4.14.3/konsole-4.14.3/src/Session.cpp
@@ -289,15 +289,15 @@
 }
 ProcessInfo* Session::updateWorkingDirectory()
 {
-    ProcessInfo* process = getProcessInfo();
-
-    const QString currentDir = process->validCurrentDir();
+    updateSessionProcessInfo();
+
+    const QString currentDir = _sessionProcessInfo->validCurrentDir();
     if (currentDir != _currentWorkingDir) {
         _currentWorkingDir = currentDir;
         emit currentDirectoryChanged(_currentWorkingDir);
     }
 
-    return process;
+    return 0; // not used - for BIC in KDE 4.14.x
 }
 
 QList<TerminalDisplay*> Session::views() const
@@ -989,7 +989,8 @@
 QString Session::getDynamicTitle()
 {
     // update current directory from process
-    ProcessInfo* process = updateWorkingDirectory();
+    updateWorkingDirectory();
+    ProcessInfo* process = getProcessInfo();
 
     // format tab titles using process info
     bool ok = false;

I think the problem lies on that line where the null reference is returned.
Comment 1 Julian Steinmann 2018-10-24 19:54:25 UTC
Even though the null reference does not exist any more, I can still reproduce this bug.

SYSTEMINFO:
Konsole 18.08.2
KDE Plasma 5.14.1
KDE Neon Developer Edition (Stable)
Comment 2 Egmont Koblinger 2018-10-24 20:37:30 UTC
3.5 years after the original report, I'm not sure the proposed patch (adjusting the way Konsole digs under /proc to figure out the tree of descendants, which may happen to break who knows what else) takes the right approach.

Konsole already supports OSC 7 for setting its belief about the working directory. In my opinion Midnight Commander should use this, that is, https://midnight-commander.org/ticket/3088 should be completed and submitted to mc.
Comment 3 Julian Steinmann 2018-10-29 20:08:41 UTC
After further investigation, I agree with Egmont. It does not make sense to implement a workaround for a specific app when the app does already have a patch ready to go which also makes it work better with other terminal emulators. Please comment on https://midnight-commander.org/ticket/3088 to push their patch forward. Thanks!