Le 29 mai 09 à 20:47, Frank Niessink a écrit : > > > 2009/5/29 Jérôme Laheurte <[email protected]>: > > > > When the session terminates (log off, reboot, shutdown) while Task > > Coach is running, the app exits without the frame having been > notified > > that it's closing. This can obviously lead to data loss (think of a > > laptop automatically shutting down because of low power) but it has > > also other consequences: the last opened file is not remembered, the > > task file is still locked, probably some others. > > > > There seems to be a notification system (EVT_QUERY_END_SESSION) that > > we use precisely to avoid blocking the shutdown process with a > dialog > > box, so I guess the potential data loss has been considered a lesser > > evil. Unfortunately, this mechanism works only under Windows (I > didn't > > try MacOS but it sure doesn't work under Linux with the latest wx). > > At least on Windows, app's get send the EVT_QUERY_END_SESSION event to > give them a chance to properly close files and the like. However, I've > never fully understood how this works. In TC we bind the > EVT_QUERY_END_SESSION event, but the handler does nothing and the > comment says: "This makes sure we don't block shutdown on Windows"...? > >
Yes, I think that the default handler closes all frames, thus popping a dialog box in case of a dirty file and blocking the shutdown process; by not calling evt.Skip() we avoid this but then changes are lost and the file is not unlocked. > Anyway, TC does behave as it should far as I can tell: just this > afternoon as I was on my way home I shut down my work laptop and the > shutdown process was temporarily blocked by Task Coach, asking me if I > wanted to save my changes or not. > > That's real strange. I have put some debug traces, and when I shutdown the OS (XP SP2), onClose is not called. I haven't tried with a dirty file though, but the lock remains. This is even more true on Mac/Linux because the whole EVT_END_SESSION stuff is not supported... > > 1) Handle the case under Win32 by releasing the lock when the system > > shuts down > > Which should happen if mainwindow.quit() is called, which is called by > mainwindow.onClose() which is called when the app is forcibly quit, so > this should already work. > > See above :) > > 2) Make the "don't prompt if there are modifications when closing" > an > > option, off by default, because I think most people are in front of > > their computer when they shut it down and don't want to lose data > > I'd rather not have an additional option for this. We have (too?) many > options already. > > Then we should find a suitable default behaviour. Hans' suggestions in this thread seem OK for me. > > 3) Somehow work around the wx limitation in order to do 1) on Linux > > and MacOS too. This will probably involve platform-specific code > using > > ctypes and maybe pyobjc, I'll try to dig this this week-end. > > It would be weird if we're the first ones being bitten by this, I'll > try to do some Google magic. > The irony is that Windows is the only system for which I know a workaround :) Cheers Jérôme
