Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-08

Strange interaction between combox and IniPropStorage

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

I just found a very strange bug:
when I try to save the ItemIndex of a combobox through a TIniPropStorage, its value reverts to the value it had when the form was created.
Every other value (I use TEdit.Text and TSpinEdit.Value) is correctly saved, it's just the TCombobox.Itemindex that does that *unless* I reference it before the TIniPropstorage tries to save it. I attached a sample project in this bug:

http://bugs.freepascal.org/view.php?id=28514

I suppose it's a regression, since I have used this combination (combobox and inipropstorage) in many projects and never saw this before.

Note that if you just create a new project and put the combobox and the inipropstorage on the main form, it works fine, maybe it has something to do with the ShowModal I'm using to show the form.

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Luca Olivetti
to Luca Olivetti

El 11/08/15 a les 12:12, Luca Olivetti ha escrit:

Show quoted text 17 lines
I just found a very strange bug: when I try to save the ItemIndex of a combobox through a TIniPropStorage, its value reverts to the value it had when the form was created. Every other value (I use TEdit.Text and TSpinEdit.Value) is correctly saved, it's just the TCombobox.Itemindex that does that *unless* I reference it before the TIniPropstorage tries to save it. I attached a sample project in this bug: http://bugs.freepascal.org/view.php?id=28514 I suppose it's a regression, since I have used this combination (combobox and inipropstorage) in many projects and never saw this before. Note that if you just create a new project and put the combobox and the inipropstorage on the main form, it works fine, maybe it has something to do with the ShowModal I'm using to show the form.

Nope, I tried also with a plain Show and it happens just the same (even tried to set the modalResult of both buttons to mrNone).

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Luca Olivetti
to Luca Olivetti

El 11/08/15 a les 12:22, Luca Olivetti ha escrit:

Show quoted text 23 lines
El 11/08/15 a les 12:12, Luca Olivetti ha escrit: > I just found a very strange bug: > when I try to save the ItemIndex of a combobox through a > TIniPropStorage, its value reverts to the value it had when the form was > created. > Every other value (I use TEdit.Text and TSpinEdit.Value) is correctly > saved, it's just the TCombobox.Itemindex that does that *unless* I > reference it before the TIniPropstorage tries to save it. > I attached a sample project in this bug: > > http://bugs.freepascal.org/view.php?id=28514 > > I suppose it's a regression, since I have used this combination > (combobox and inipropstorage) in many projects and never saw this before. > > Note that if you just create a new project and put the combobox and the > inipropstorage on the main form, it works fine, maybe it has something > to do with the ShowModal I'm using to show the form. Nope, I tried also with a plain Show and it happens just the same (even tried to set the modalResult of both buttons to mrNone).

Definitely a regression: I just had to modify an old program (where this feature worked) and it doesn't work anymore :-(
At least the workaround seems to do the job.

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Luca Olivetti
to Luca Olivetti

El 12/08/15 a les 16:37, Luca Olivetti ha escrit:

Definitely a regression: I just had to modify an old program (where this feature worked) and it doesn't work anymore :-( At least the workaround seems to do the job.

It's not a regression, it's probably always been there, but I manually called SaveProperties previously, but since the IniPropstorage does it automatically, I removed my call.
*However* it calls it when the form is being freed, and in that case the combobox returns the previous itemindex, not the changed one. I added a comment and a couple of possible patches in the bugreport.

http://bugs.freepascal.org/view.php?id=28514

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Flávio Etrusco
to Luca Olivetti
Luca Olivetti wrote 16 lines
El 12/08/15 a les 16:37, Luca Olivetti ha escrit: > > Definitely a regression: I just had to modify an old program (where this > feature worked) and it doesn't work anymore :-( > At least the workaround seems to do the job. It's not a regression, it's probably always been there, but I manually called SaveProperties previously, but since the IniPropstorage does it automatically, I removed my call. *However* it calls it when the form is being freed, and in that case the combobox returns the previous itemindex, not the changed one. I added a comment and a couple of possible patches in the bugreport. http://bugs.freepascal.org/view.php?id=28514

Good job. I would add a comment explaining the need for the GetItemIndex call, however ;-)
I recall combobox went through various iteations to fix synchronizing state between the LCL and the underlying widgetset...

Best regards,
Fl?vio

Reply by email

Luca Olivetti
to Luca Olivetti: El 12/08/15 a les 16:37, Luca Olivetti ha escrit: It's not a regression, it's probably…

El 13/08/15 a les 09:24, Luca Olivetti ha escrit:

Show quoted text 15 lines
El 12/08/15 a les 16:37, Luca Olivetti ha escrit: > > Definitely a regression: I just had to modify an old program (where this > feature worked) and it doesn't work anymore :-( > At least the workaround seems to do the job. It's not a regression, it's probably always been there, but I manually called SaveProperties previously, but since the IniPropstorage does it automatically, I removed my call. *However* it calls it when the form is being freed, and in that case the combobox returns the previous itemindex, not the changed one. I added a comment and a couple of possible patches in the bugreport. http://bugs.freepascal.org/view.php?id=28514

I see that the patch hasn't been merged in 1.4.4.
Please keep it in mind for 1.4.6

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Juha Manninen
to Luca Olivetti
Luca Olivetti wrote
I see that the patch hasn't been merged in 1.4.4. Please keep it in mind for 1.4.6

I aded it now here:
http://wiki.freepascal.org/Lazarus_1.4_fixes_branch

You can add commits there, too, in the "Submitted by others" section. Often it is difficult to decide what fixes need more time testing in trunk and which ones are crucial enough to be merged. Usually I add only fixes that I feel are important, which is very subjective of course.

Juha

Reply by email