Bug 504269 - [Feature Request] Ability to lock session so it cant create new ones
Summary: [Feature Request] Ability to lock session so it cant create new ones
Status: RESOLVED INTENTIONAL
Alias: None
Product: kdevelop
Classification: Applications
Component: UI: general (other bugs)
Version First Reported In: git master
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-15 14:33 UTC by Ian H
Modified: 2025-05-20 09:08 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian H 2025-05-15 14:33:25 UTC
Is it possible to add a locking mechanism to prevent creating a new session when accidentally clicking it?

i will consistently click new session when i'm hitting my build button on the toolbar. normally it wouldnt be a huge issue, because i can just close it again, but right now even if you close it, if kdevelop crashes, it will reopen the closed session instead of the one you want to keep (since it was the last one opened)
Comment 1 Igor Kushnir 2025-05-15 17:10:30 UTC
Do you accidentally trigger the Start New Session action in the main menu=>Session? Or a new session button on the same toolbar as the Build button? Toolbar actions can be edited in Settings=>Configure Toolbars... If you somehow accidentally trigger the main menu action, you could move the Build button or its entire toolbar elsewhere. Or use the shortcut (F8 by default).
Comment 2 Ian H 2025-05-16 12:10:16 UTC
it's from the main menu. and actually there definitely seems to be a bug related to this. 

1. Create new session
2. close new session
3. close kdevelop
4. open kdevelop

Actual behavior:
opens an empty session

Expected behavior: 
Should open original session
Comment 3 Igor Kushnir 2025-05-16 12:42:43 UTC
(In reply to Ian H from comment #2)
> Actual behavior:
> opens an empty session
> 
> Expected behavior: 
> Should open original session
SessionController::initialize() deletes unnamed sessions without projects on KDevelop start. Without command line arguments, SessionController::loadDefaultSession() attempts to load the last opened or created session stored in ~/.config/kdeveloprc at [Sessions]|"Active Session ID". If that fails, loadDefaultSession() creates a new session. The penultimate session ID is not stored in config and therefore cannot be opened.

If you always use the same session, you can create a launcher (a .desktop file) with two arguments to the kdevelop executable `-s "<session name>"` and launch it instead of the default KDevelop launcher.
Comment 4 Ian H 2025-05-16 12:45:31 UTC
(In reply to Igor Kushnir from comment #3)
> (In reply to Ian H from comment #2)
> > Actual behavior:
> > opens an empty session
> > 
> > Expected behavior: 
> > Should open original session
> SessionController::initialize() deletes unnamed sessions without projects on
> KDevelop start. Without command line arguments,
> SessionController::loadDefaultSession() attempts to load the last opened or
> created session stored in ~/.config/kdeveloprc at [Sessions]|"Active Session
> ID". If that fails, loadDefaultSession() creates a new session. The
> penultimate session ID is not stored in config and therefore cannot be
> opened.
is it possible for kdevelop to get the session id of the one open if you close a session and store that in the kdeveloprc file? seems to me that if you delete a session, it probably shoulnt be remembering that deleted session... since you clearly dont want it anymore
Comment 5 Igor Kushnir 2025-05-16 12:53:26 UTC
(In reply to Ian H from comment #4)
> is it possible for kdevelop to get the session id of the one open if you
> close a session and store that in the kdeveloprc file? seems to me that if
> you delete a session, it probably shoulnt be remembering that deleted
> session... since you clearly dont want it anymore
The empty project-less session is deleted the next time KDevelop starts, so the other last-open session cannot be easily used instead. If you use only a few sessions, create separate launchers for them instead of relying on the last one being opened again. Or use the other default launcher "KDevelop (Pick Session)".
Comment 6 Igor Kushnir 2025-05-20 09:08:43 UTC
(In reply to Ian H from comment #0)
> Is it possible to add a locking mechanism to prevent creating a new session
> when accidentally clicking it?
This appears to be a rarely useful, obscure feature, which could end up confusing more often than helpful.
> i will consistently click new session when i'm hitting my build button on
> the toolbar.
I have listed several workarounds for such accidental triggering of the Start New Session action. A more general solution is to change your system UI configuration so as not to trigger actions accidentally in any application.