Version: 4.1 (using KDE 3.0.7 (KDE 3.1 beta1)) Installed from: compiled sources Compiler: gcc version 2.95.4 20011002 (Debian prerelease) OS: Linux (ppc) release 2.4.19-powerpc All instances of kwrite are restored with an empty document instead of the document open when exiting the session. If you watch carefully, you can see the documents closing before the session exits -- this is probably the problem.
The problem is not kwrite specific, Kate exhibits problems with session restore too. E.g. start Kate with no files open (i.e. only Untitled 1), type something, start logout, confirm file save and save it. On next KDE startup empty Untitled 1 is open. If the file is saved explicitly using Ctrl+S before logging out, it's restored correctly (it's also interesting to note that in the Ctrl+S case a dialog warning about overwriting an existing file opens while in the first case it does not). Also, if there are any Ctrl+S saved files open when editing one Untitled, they're not in the documents list when confirming save, and are also not restored. I'm assuming that either Kate closes the files when doing session save (which is wrong, session shutdown may be cancelled), or it tries handling session file saving completely on its own and isn't very good at it (which is not very good either, even if it worked).
This bug was introduced in revision 1.32 of kwritemain.cpp. The cause is calling KateDocument::closeURL() from queryClose(). KateDocument::closeURL() calls ReadWritePart::closeURL(), which first displays the "Save Changes?" dialog, and then closes the URL if appropriate. We want the first part, but not the second. The ideal solution is to factor out the "Save Changes?" part of ReadWritePart::closeURL() into a new function (suggested name: queryClose()). It probably should be virtual, but can survive until 4.0 without that, I think. It can then be called from both ReadWritePart::closeURL() and KWrite::queryClose(). Comments?
Created attachment 815 [details] KParts::queryClose implementation I agree with John's assessment, so I implemented it :) Works fine here. (Although I am seeing a few other problems with kate, they're 99% likely to be other bugs). Ok to commit? backport?
Created attachment 816 [details] The kwrite part of this patch.
Subject: Re: session management doesn't work On Monday 27 January 2003 06:30, you wrote: > I agree with John's assessment, so I implemented it :) Works fine here. > (Although I am seeing a few other problems with kate, they're 99% likely to be > other bugs). > > Ok to commit? backport? Now I'm surprised. I thought I saw a patch on kde-core-devel which implemented queryClose in KParts::ReadWritePart already. Ah yes. The patch was from John :) http://lists.kde.org/?l=kde-core-devel&m=103958666221160&w=2 I thought it was applied by now. Comparing your patches: John's had an additionnal closeURL(bool promptToSave) which I didn't like very much (but accepted nonetheless). Its docu said "to avoid prompting twice, when prompting would be done by both queryClose and closeURL". How is this solved in Hamish's patch? Anyway, I'm fine with either version - please sort out which one you want to commit :)
Subject: Re: session management doesn't work On Monday 27 January 2003 21:06, David Faure wrote: > On Monday 27 January 2003 06:30, you wrote: > > I agree with John's assessment, so I implemented it :) Works fine here. > > (Although I am seeing a few other problems with kate, they're 99% likely > > to be other bugs). > > > > Ok to commit? backport? > > Now I'm surprised. I thought I saw a patch on kde-core-devel which > implemented queryClose in KParts::ReadWritePart already. > > Ah yes. The patch was from John :) > http://lists.kde.org/?l=kde-core-devel&m=103958666221160&w=2 > I thought it was applied by now. Doesn't appear so to me... > Comparing your patches: John's had an additionnal closeURL(bool > promptToSave) which I didn't like very much (but accepted nonetheless). Its > docu said "to avoid prompting twice, when prompting would be done by both > queryClose and closeURL". How is this solved in Hamish's patch? Ah, I guess it's not, except that I thought this was only for when you want to not close the document? I didn't look too hard at the issues with this. > Anyway, I'm fine with either version - please sort out which one you want > to commit :) John, any reason you didn't commit yours? Cheers, Hamish.
> John, any reason you didn't commit yours? Only that I, like David, wasn't completely satisfied with it. But, of all the suggested solutions, it still seems like the best to me. I'll commit in the next few days.
Now understanding the issue (I think :), a suggestion: you could add the bool argument to the queryClose() function instead (eg. queryClose(bool promptOnClose = false)) and store the result for use in closeURL() (or inside queryClose itself) instead of duplicating closeURL. It looks like you'd need to use Qt's property system to store it though, it doesn't seem to me that there's a d pointer available... or make readonlypart expose a new bool from it's private class though a function.
I'm leaving on a trip very soon so actually I'm not going to have a chance to double-check and commit this patch. Hamish and David, I guess you two should go ahead and apply whatever variation you agree on.
Created attachment 1135 [details] Next revision of my proposed patch This patch incorporates a different approach to preventing the queryClose prompt from being displayed twice. queryClose now has a parameter, promptOnClose, which can be set to false to prevent closeURL from calling queryClose. This avoids the need for a second closeURL() function. This is implemented with a static QMap as there is no d-pointer. Comments, ok to apply? (backport?)
perhaps you should send the patch to core-devel, or we never get a reply ;)
Subject: kdebase/kate/app CVS commit by firebaugh: Fix bug #49270, session management doesn't work: use the new ReadWritePart method queryClose() instead of closeURL(). CCMAIL: 49270-done@bugs.kde.org M +3 -3 kwritemain.cpp 1.63 --- kdebase/kate/app/kwritemain.cpp #1.62:1.63 @@ -131,6 +131,6 @@ void KWrite::loadURL(const KURL &url) bool KWrite::queryClose() { - if (!(kateView->document()->views().count() == 1)) return true; - return kateView->document()->closeURL(); + return kateView->document()->views().count() != 1 + || kateView->document()->queryClose(); }
*** Bug 64524 has been marked as a duplicate of this bug. ***
This problem is back in HEAD.
for kate or kwrite ? kate works here perfect
hmm, true, kwrite session restore was borked (not showing the reopened files + the other bug with the crash after closing the kwrite) fixed now in cvs, not the perfect fix, but works
this fix seems to only work for kde: i run xfce4-session and kwrite does NOT properly save it's state (the file that was open does not restore but an empty kwrite loads) see xfce4 bug here: http://bugzilla.xfce.org/show_bug.cgi?id=733 please reopen this bug