Bug 385916

Summary: Filesystem tool view is opened after KDevelop restart
Product: [Applications] kdevelop Reporter: Silviu <laurentiusilviu>
Component: All build toolsAssignee: Igor Kushnir <igorkuo>
Status: RESOLVED FIXED    
Severity: normal CC: igorkuo
Priority: NOR    
Version First Reported In: 5.1.2   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In: 6.2.250400
Sentry Crash Report:

Description Silviu 2017-10-18 15:30:02 UTC
I opened KDevelop
  I pressed right click on Filesystem tool view from left bar
  Filesystem tool view is closed
  I restarted KDevelop
  Filesystem in opened again even it was closed before to restart KDevelop
Comment 1 Justin Zobel 2022-11-10 08:52:52 UTC
Thank you for reporting this issue in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "REPORTED" when replying. Thank you!
Comment 2 Bug Janitor Service 2022-11-25 05:18:49 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Bug Janitor Service 2022-12-10 05:15:44 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!
Comment 4 Igor Kushnir 2025-01-20 20:18:51 UTC
The bug still exists in KDevelop 6.2 (master). I have implemented a fix and will create a merge request soon.
Comment 5 Igor Kushnir 2025-01-20 20:21:04 UTC
This bug is cross-platform as I can reproduce it every time on my GNU/Linux system. The root cause is that the file system plugin is initialized asynchronously since http://commits.kde.org/kdevplatform/e85e6380ab36c1bd53ee92fea11431bc6b26d6b7 .
Comment 6 Bug Janitor Service 2025-01-24 19:59:43 UTC
A possibly relevant merge request was started @ https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/715
Comment 7 Igor Kushnir 2025-02-10 15:45:29 UTC
Git commit 90f2a156da8d9f7eb1aa59df3fcf19eda763dec3 by Igor Kushnir.
Committed on 10/02/2025 at 14:30.
Pushed by igorkushnir into branch 'master'.

Initialize KDevFileManagerPlugin synchronously

UiController::loadAllAreas() adds a tool view to a sublime area only if
the tool view is in the area's list of desired views. This list is
stored in ~/.config/kdeveloprc at the "desired views" key of the config
groups [User Interface][Main Window 0][Area <name>]. This configuration
preserves sets of tool views available in dock widget areas when the
user switches between sublime areas or restarts KDevelop.

UiController::addToolView() does not add to sublime areas but only
registers the tool view if called before loadAllAreas() returns. But if
addToolView() is called after loadAllAreas(), it adds the tool view to
all areas unconditionally.

KDevFileManagerPlugin() invokes KDevFileManagerPlugin::init()
asynchronously. init() adds the "File System" tool view via
IUiController::addToolView(). Consequently, this tool view is added
after loadAllAreas() returns on KDevelop start. And therefore the
"File System" tool view is always added at its default position when
KDevelop starts, whether or not the "desired views" config of the
current sublime area contains it. As a result, removing the
"File System" tool view and restarting KDevelop results in the tool view
reappearing in its default (left) dock widget area.

All other plugins, which add their tool views on KDevelop start, do so
synchronously. Therefore, tool views other than the "File System" do not
reappear on next KDevelop start after being removed. Remove
KDevFileManagerPlugin::init() and inline its definition into the single
invoking function KDevFileManagerPlugin() in order to add the
"File System" tool view synchronously and eliminate the bug.

KDevFileManagerPlugin::init() is invoked asynchronously since
e85e6380ab36c1bd53ee92fea11431bc6b26d6b7. The asynchronous loading
worked around a crash when the user enabled the "KDE File Manager
Integration" plugin on the Plugins tab of the Configure KDevelop dialog.
The crash occurred because in this scenario the plugin is loaded and
UiController::addToolView() is invoked long after KDevelop starts. So
addToolView() adds the "File System" tool view to all areas, which
creates a FileManager object, which in turn creates a BookmarkHandler
object, which in turn invokes Session::pluginDataArea(). All this
happened during the construction of KDevFileManagerPlugin(), that is
before its insertion into PluginController's list of loaded plugins.
Session::pluginDataArea() asked PluginController for the ID of
KDevFileManagerPlugin absent from the list of loaded plugins. This used
to crash before, but now returns an empty string as the plugin ID, and
thus silently makes BookmarkHandler use the wrong bookmarks path in this
scenario.

The function ISession::pluginDataArea() is used in the single place -
BookmarkHandler(), where it silently breaks the synchronous
initialization of KDevFileManagerPlugin. Replace the error-prone
function with a much simpler and reliable alternative
ISession::dataDirectory(). Hard-code the plugin ID "kdevfilemanager" in
BookmarkHandler() to eliminate the wrong bookmarks path bug. Spell out
and preserve the odd-looking long filename of the bookmarks path for
backward compatibility and explain it in a comment.

Remove no longer used KDevFileManagerPlugin* data members, getters and
constructor parameters, as well as includes and forward declarations.
FIXED-IN: 6.2.250400

M  +4    -3    kdevplatform/interfaces/isession.h
M  +3    -22   kdevplatform/shell/session.cpp
M  +1    -2    kdevplatform/shell/session.h
M  +6    -4    plugins/filemanager/bookmarkhandler.cpp
M  +2    -8    plugins/filemanager/filemanager.cpp
M  +1    -4    plugins/filemanager/filemanager.h
M  +4    -11   plugins/filemanager/kdevfilemanagerplugin.cpp
M  +0    -2    plugins/filemanager/kdevfilemanagerplugin.h

https://invent.kde.org/kdevelop/kdevelop/-/commit/90f2a156da8d9f7eb1aa59df3fcf19eda763dec3