Bug 447872 - konsole starts with Root Shell as default
Summary: konsole starts with Root Shell as default
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 21.12.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-03 10:30 UTC by Jiri Slaby
Modified: 2022-01-04 04:25 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 21.12.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Slaby 2022-01-03 10:30:58 UTC
SUMMARY
Likely after update from 21.08.3 to 21.12.0, konsole starts with Root Shell profile as the default.

STEPS TO REPRODUCE
1. run konsole
2. set some profile (not the Root Shell) as default
3. run konsole
4. the Root Shell is reset as default again

OBSERVED RESULT
In step 3, Root Shell is started

EXPECTED RESULT
The selected profile from step 2 should start.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220101
KDE Plasma Version: 5.23.4
KDE Frameworks Version: 5.89.0
Qt Version: 5.15.2
Kernel Version: 5.15.10-1.g85804f3-default (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i7-6600U CPU @ 2.60GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 520

ADDITIONAL INFORMATION
$ grep ltProfile ~/.config/konsolerc 
DefaultProfile=Shell.profile
$ cat /home/xslaby/.local/share/konsole/Shell.profile
[Appearance]
AntiAliasFonts=false
ColorScheme=WhiteOnBlack
DimmValue=43
Font=Misc Fixed,10,-1,5,57,0,0,0,0,0,SemiCondensed
UseFontLineChararacters=true

[Cursor Options]
CursorShape=0

[General]
DimWhenInactive=true
InvertSelectionColors=true
LocalTabTitleFormat=%d : %n (%w)
Name=Shell
Parent=FALLBACK/
TerminalColumns=80
TerminalRows=25

[Keyboard]
KeyBindings=default

[Scrolling]
BlinkingCursorEnabled=false
HistorySize=10000
ScrollBarPosition=2
VerticalLine=true
Comment 1 Jiri Slaby 2022-01-03 10:33:32 UTC
This opens the profile just fine. 
$ konsole --profile Shell
It's just [Desktop Entry].DefaultProfile cannot be loaded somehow and Root Shell is used instead (and also set as the default).

The same profile is mis-loaded in dolphin by F4.
Comment 2 Jiri Slaby 2022-01-03 12:06:39 UTC
Bisected to:
commit 50041fd02ee42cf2cd484f91869896419e09ef83 (HEAD)
Author: Ahmad Samir <a.samirh78@gmail.com>
Date:   Wed Aug 11 13:38:12 2021 +0200

    Simplify ProfileManager code
    
    Now all the profiles are loaded in the constructor; I didn't see any
    noticeable difference in loading times.
    
    Also all the profiles are loaded anyway because ProfileList calls
    ProfileManager::allProfiles() to populate the profiles menu ...etc.
Comment 3 Ahmad Samir 2022-01-03 12:12:46 UTC
I think I see what's causing this, I'll create an MR shortly.
Comment 4 Jiri Slaby 2022-01-03 12:13:26 UTC
(In reply to Ahmad Samir from comment #3)
> I think I see what's causing this, I'll create an MR shortly.

It's likely the endsWith...
Comment 5 Jiri Slaby 2022-01-03 12:13:57 UTC
(In reply to Jiri Slaby from comment #4)
> (In reply to Ahmad Samir from comment #3)
> > I think I see what's causing this, I'll create an MR shortly.
> 
> It's likely the endsWith...

And
Root Shell.profile
vs
Shell.profile
Comment 6 Jiri Slaby 2022-01-03 12:22:00 UTC
I believe you'll come up with sth like:
--- a/src/profile/ProfileManager.cpp
+++ b/src/profile/ProfileManager.cpp
@@ -211,7 +211,7 @@ void ProfileManager::loadAllProfiles(const QString &defaultProfileFileName)
     const QStringList &paths = availableProfilePaths();
     for (const QString &path : paths) {
         Profile::Ptr profile = loadProfile(path);
-        if (profile && !defaultProfileFileName.isEmpty() && path.endsWith(defaultProfileFileName)) {
+        if (profile && !defaultProfileFileName.isEmpty() && QFileInfo(path).fileName() == defaultProfileFileName) {
             _defaultProfile = profile;
         }
     }
Comment 7 Bug Janitor Service 2022-01-03 12:27:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/570
Comment 8 Ahmad Samir 2022-01-03 12:29:20 UTC
True, it's a variation of the same solution you posted. :-)
Comment 9 Axel Braun 2022-01-03 12:39:26 UTC
Same behaviour if you open a shell from dolphin with F4...
Comment 10 Ahmad Samir 2022-01-03 12:41:37 UTC
(In reply to Axel Braun from comment #9)
> Same behaviour if you open a shell from dolphin with F4...

Both use-cases use the same code, so it should be fixed for both of them.
Comment 11 Jiri Slaby 2022-01-03 12:42:45 UTC
(In reply to Ahmad Samir from comment #10)
> (In reply to Axel Braun from comment #9)
> > Same behaviour if you open a shell from dolphin with F4...
> 
> Both use-cases use the same code, so it should be fixed for both of them.

Confirmed.
Comment 12 Ahmad Samir 2022-01-03 12:45:26 UTC
Git commit 10c306004210671579154947caaf9ea7f1d9b993 by Ahmad Samir.
Committed on 03/01/2022 at 12:25.
Pushed by ahmadsamir into branch 'master'.

Use tighter matching when finding the default profile file name

The code was checking if the path ended with a specific file name, which
meant that if you have two profiles "Root Shell.profile" and
"Shell.profile", the matching is messed up because the former ends with
the latter. Instead since we're using the path, add a '/', this way we're
matching the whole file name which is the last component in the path after
the last '/'.

Thanks to the bug reporter for git bisect'ing the repo to find the culprit
commit.
FIXED_IN: 21.12.0

M  +1    -1    src/profile/ProfileManager.cpp

https://invent.kde.org/utilities/konsole/commit/10c306004210671579154947caaf9ea7f1d9b993
Comment 13 Ahmad Samir 2022-01-03 12:48:32 UTC
Git commit eb44240235fa61e662e9a521f72e8be9213bb536 by Ahmad Samir.
Committed on 03/01/2022 at 12:48.
Pushed by ahmadsamir into branch 'release/21.12'.

Use tighter matching when finding the default profile file name

The code was checking if the path ended with a specific file name, which
meant that if you have two profiles "Root Shell.profile" and
"Shell.profile", the matching is messed up because the former ends with
the latter. Instead since we're using the path, add a '/', this way we're
matching the whole file name which is the last component in the path after
the last '/'.

Thanks to the bug reporter for git bisect'ing the repo to find the culprit
commit.
FIXED_IN: 21.12.0

M  +1    -1    src/profile/ProfileManager.cpp

https://invent.kde.org/utilities/konsole/commit/eb44240235fa61e662e9a521f72e8be9213bb536