Don't clear the session KConfing object too early
AbandonedPublic

Authored by cullmann on Jun 24 2019, 9:02 AM.

Details

Reviewers
dhaumann
ahmadsamir
Group Reviewers
Kate
Summary

The session KConfig object was cleared in finishRestore(), which meant
that for plugins that aren't loaded when we start loading the session,
the sidebar position - and other toolview related - settings weren't
restored for such plugins. A perfect example of this is the Projects
plugin where the toolview for it is only shown if you open a file that
belongs to a git/svn/mercury repo.

BUG: 391715
FIXED-IN: 19.08.0

Test Plan
  • Open a document in kate, that doesn't belong to a git/svn/mercury repo
  • Make sure the Projects plugin is enabled and "Git" is checked in that plugin config page; then open a document that belongs to a git repo, this causes the Projects toolview to show
  • Move the Projects plugin panel to the right side bar
  • Close that file then close kate
  • Start kate again but don't initially open a file that belongs to a git repo
  • Now open a file from a git repo, notice that the Projects panel is shown on the left sidebar, even though the previously saved position was on the right sidebar
  • Apply the diff then try again, the Projects panel should appear on the right sidebar

Diff Detail

Repository
R40 Kate
Branch
plugin-sidebar-position (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 13254
Build 13272: arc lint + arc unit
ahmadsamir created this revision.Jun 24 2019, 9:02 AM
Restricted Application added a project: Kate. · View Herald TranscriptJun 24 2019, 9:02 AM
ahmadsamir requested review of this revision.Jun 24 2019, 9:02 AM
cullmann requested changes to this revision.Jun 24 2019, 7:15 PM

Perhaps I did something very wrong, but with your patch applied, I can no longer use the "move to right sidebar" at all.
I will just do nothing ;)

This revision now requires changes to proceed.Jun 24 2019, 7:15 PM

Taking a look at the code, I think one can not just keep that pointer/group around that long.

One could try to e.g. remember the keys with values for positions in finishRestore() and use that as overwrite in createToolView like we do there with

// try the restore config to figure out real pos
if (m_restoreConfig && m_restoreConfig->hasGroup(m_restoreGroup)) {
    KConfigGroup cg(m_restoreConfig, m_restoreGroup);
    pos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry(QStringLiteral("Kate-MDI-ToolView-%1-Position").arg(identifier), int(pos));
}

As long as the config pointer is valid, no operation showing/moving toolviews will have any effect.

Taking a look at the code, I think one can not just keep that pointer/group around that long.

One could try to e.g. remember the keys with values for positions in finishRestore() and use that as overwrite in createToolView like we do there with

// try the restore config to figure out real pos
if (m_restoreConfig && m_restoreConfig->hasGroup(m_restoreGroup)) {
    KConfigGroup cg(m_restoreConfig, m_restoreGroup);
    pos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry(QStringLiteral("Kate-MDI-ToolView-%1-Position").arg(identifier), int(pos));
}

As long as the config pointer is valid, no operation showing/moving toolviews will have any effect.

Yep, there must have been a good reason why those two variables were cleared at the end of finishRestore(); I should have looked closer for that reason; I'll rework the diff. (Sorry about the noise).

Looking closer at this, it's more complicated than I initially thought :)

The location inside a sidebar, persistence and visibility settings of a tool view are only read from the config in Sidebar::restoreSession(); so at best with the create-toolview-on-demand nature of the projects plugin, we can only set the saved position setting. I'd say that's OK, because this diff here is more about the anonymous session, which is a special case.

If the user has a named-saved session, most of the time if he has files from a git/svn/hg repo open, he's probably not going to close them before saving the session or quitting kate.

So, just restoring the position setting would be OK?

Incidentally, why is the projects plugin has its tool views created on demand? that point doesn't seem to be documented (hint: you should document it :)).

Looking closer at this, it's more complicated than I initially thought :)

The location inside a sidebar, persistence and visibility settings of a tool view are only read from the config in Sidebar::restoreSession(); so at best with the create-toolview-on-demand nature of the projects plugin, we can only set the saved position setting. I'd say that's OK, because this diff here is more about the anonymous session, which is a special case.

If the user has a named-saved session, most of the time if he has files from a git/svn/hg repo open, he's probably not going to close them before saving the session or quitting kate.

So, just restoring the position setting would be OK?

Incidentally, why is the projects plugin has its tool views created on demand? that point doesn't seem to be documented (hint: you should document it :)).

Scratch all of the above...

OK. Here's where I am at the moment. If we store the position of the project and projectinfo plugin (one plugin, two tool views), if the user opens another session in the same window, things start getting messy as now there will be the position of the first session and the second session, so now we'd have to store the session name along with the position... this is starting to become too complicated for such a small issue.

I think this needs some more thoughts.
One could save all stored positions/... during session restore and use them on tool view creation if set.
But this is a much larger change.

cullmann commandeered this revision.Jul 7 2019, 2:17 PM
cullmann edited reviewers, added: ahmadsamir; removed: cullmann.

As said, I think this needs to be handled differently.
If you have a new patch, please submit a new review, thanks!

cullmann abandoned this revision.Jul 7 2019, 2:17 PM