https://bugs.kde.org/show_bug.cgi?id=427552

            Bug ID: 427552
           Summary: KMainWindow::canBeRestored(1) inappropriately returns
                    true when there is no session restore data
           Product: frameworks-kxmlgui
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Consider the following code:

KConfigGui::setSessionConfig(QStringLiteral("myApp"), QStringLiteral("myApp"));
if (KMainWindow::canBeRestored(1)) {
    // do a bunch of stuff
}


KMainWindow::canBeRestored(1) will return true even though the newly-created
session config is empty. This is because internally, it's doing this:

const int n = group.readEntry("NumberOfWindows", 1);
return number >= 1 && number <= n;


So NumberOfWindows is not set, which causes it to fall back to 1. And then the
function returns true because the number 1 satisfies both criteria.

This can be trivially fixed by changing the default value of the readEntry()
call from 1 to 0, and that's what I did in
https://invent.kde.org/frameworks/kxmlgui/-/merge_requests/. However this so
breaks Dolphin's manual session restore feature (which accidentally takes
advantage of this bug to function) and I had to revert it.

This bug report tracks this issue so that the fix can be merged after Dolphin
and potentially other apps are fixed, or KF6--whichever comes first.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to