#1 2006-10-12 04:03

chopstks
Member
Registered: 2006-10-08
Posts: 4

INI file settings not saved

I was installing Shutter, configure the settings under General and On Action Extra, then click Save to exit.  Then I shut down the computer and then power up, surprisingly all settings were gone, like it was never saved.  It happened on at least 4 of my installed 9 computers.  Strange.  I tried uninstalling, deleted the Shutter folder, deleted the Shutter registry and reinstall, re-configure the settings, shut down and power up again, it still didn't save.  Then I went to the computer that has successfully save the ini file and copy it onto the one that is not working and it worked!  Did I do anything wrong?  Is there a reason behind this?  Can't figure out why?

Offline

#2 2006-10-12 16:04

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: INI file settings not saved

I assume you are using Windows XP (or later). You did nothing wrong!

Shutter, as the rest of my programs, save its settings when you close it. By "close it" I mean normal program termination, for example: you press a close button at the top-right corner of the window. But starting from Windows XP, EWX_FORCE flag is always set when shutdown/reboot operations are activated (read more here). This will cause applications to terminate not in a usual way, which will result in the settings not being saved Shutter and some other applications. Here is another example for you: Open Winamp, load few songs into it, and then shutdown Windows (XP or later), and after rebooting, Winamp will not have the previously loaded songs, as it usually does when you close it manually. Do you know what I mean?

When Shutter it-self is initiating a shutdown/reboot/logoff operation - it will terminate it-self straight away (in a normal way), in order to save its settings. But when you open Shutter, change few settings, and then you use initiate shutdown using Windows XP way - settings will be lost. The best solution to your problem would be to close Shutter manually, prior to shutting down the computer, in order to save settings.

Tell me how it goes for you, ok?

Offline

#3 2006-12-16 20:13

yop
Member
Registered: 2006-12-16
Posts: 1

Re: INI file settings not saved

THANK YOU !!

I had the same problem, and [ALT + F4] saved my changed settings.

Thank you for this small soft : very usefull with my terrible childs smile



den4b wrote:

I assume you are using Windows XP (or later). You did nothing wrong!

Shutter, as the rest of my programs, save its settings when you close it. By "close it" I mean normal program termination, for example: you press a close button at the top-right corner of the window. But starting from Windows XP, EWX_FORCE flag is always set when shutdown/reboot operations are activated (read more here). This will cause applications to terminate not in a usual way, which will result in the settings not being saved Shutter and some other applications. Here is another example for you: Open Winamp, load few songs into it, and then shutdown Windows (XP or later), and after rebooting, Winamp will not have the previously loaded songs, as it usually does when you close it manually. Do you know what I mean?

When Shutter it-self is initiating a shutdown/reboot/logoff operation - it will terminate it-self straight away (in a normal way), in order to save its settings. But when you open Shutter, change few settings, and then you use initiate shutdown using Windows XP way - settings will be lost. The best solution to your problem would be to close Shutter manually, prior to shutting down the computer, in order to save settings.

Tell me how it goes for you, ok?

Offline

#4 2006-12-17 15:33

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: INI file settings not saved

den4b wrote:

I assume you are using Windows XP (or later). You did nothing wrong!

Shutter, as the rest of my programs, save its settings when you close it. By "close it" I mean normal program termination, for example: you press a close button at the top-right corner of the window. But starting from Windows XP, EWX_FORCE flag is always set when shutdown/reboot operations are activated (read more here). This will cause applications to terminate not in a usual way, which will result in the settings not being saved Shutter and some other applications. Here is another example for you: Open Winamp, load few songs into it, and then shutdown Windows (XP or later), and after rebooting, Winamp will not have the previously loaded songs, as it usually does when you close it manually. Do you know what I mean?

When Shutter it-self is initiating a shutdown/reboot/logoff operation - it will terminate it-self straight away (in a normal way), in order to save its settings. But when you open Shutter, change few settings, and then you use initiate shutdown using Windows XP way - settings will be lost. The best solution to your problem would be to close Shutter manually, prior to shutting down the computer, in order to save settings.

Tell me how it goes for you, ok?

Denis, the good news is, you can cope with this fine smile
http://delphi.about.com/cs/adptips2000/ … 0500_4.htm

Last edited by dloneranger (2006-12-18 07:20)

Offline

#5 2006-12-19 18:57

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: INI file settings not saved

yop wrote:

I had the same problem, and [ALT + F4] saved my changed settings.

Good to hear that! It should be fixed now, try downloading the latest dev version: ShutterBeta.zip

dloneranger wrote:

Denis, the good news is, you can cope with this fine

I knew about this workaround, but when I finally started solving this issue - I WAS ABSOLUTELY SHOCKED!!! I put the code for saving settings in two places, half in MainForm.OnDestroy and the rest in FINALIZATION section of one of the units! After messing for few hours, I eventually found out that code in FINALIZATION section DID NOT GET EXECUTED when user does manual shutdown or log off! yikes yikes yikes

That's amazing stuff! Sometimes Delphi's way of doing things really puts me back....

By the way, can you clarify that Form.OnDestroy will get executed NO MATTER WHAT???
Ofcourse, unless power goes down! tongue

Offline

#6 2006-12-20 00:30

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: INI file settings not saved

Nope - OnDestroy/finalize have many ways of not getting executed hmm

As D7 is based on earlier versions of windows it doesn't handle many of the newer windows messages and so windows just kills it when it gets no answer
Directly handling the end session messages and the power broadcasts is the best way I've found to do it
For instance, on my pc if I press my power button once, it'll shut the pc down really quickly and my programs won't save their data unless I handle the power messages as I get sent the 'your battery is flat' message, and that's the only thing that is 'semi-reliable' (but you still don't have a long time to process before you just get killed)

Generally, this is what I do

In the form class, have a private variable FHaveSaved:boolean that is set to false on creation

In the form class, have a procedure SaveSettings(Fast:boolean=false);
This routine normally ignores the 'Fast' parameter - unless it might take longer than windows is going to give it, then I'll
just save as little as possible

Add message handlers, and link them to SaveSettings
If the saving is quick they're called as SaveSettings(false) or if it might take a long time it's called with 'true'
I can also then reuse it for immediate saves as long as any changes that are made reset FHaveSaved  to false

The nice bit is I only had to do this once, save it, and then add it to the repository as the default main form
From then on, every new project has all the bits in place, and all I have to do is fill in the blanks

Offline

#7 2006-12-20 22:03

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: INI file settings not saved

Offline

#8 2007-01-10 03:20

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: INI file settings not saved

So you recon that TForm.OnCloseQuery should be the best place to put the finalization code? hmm

OnCloseQuery is getting executed when WM_QUERYENDSESSION is sent to the app.

Offline

Board footer

Powered by FluxBB