[Lazarus] TCombobox major failure :(

Marc Weustink marc at dommelstein.net
Tue Jul 22 00:54:57 CEST 2008


Mattias Gaertner wrote:
> On Sat, 19 Jul 2008 23:05:43 -0300
> Luiz Americo Pereira Camara <luizmed at oi.com.br> wrote:
> 
>> Mattias Gaertner wrote:
>>>> Luiz Americo Pereira Camara wrote:
>>>>     
>>>>
>>>> Gtk2 is handled in an different callback function. Unlike gtk1 the 
>>>> LM_SELCHANGE message is sent inside the 'changed' event. At first
>>>> look is not possible to determine if the changed event came from
>>>> the selection list or not.
>>>>
>>>> One issue is that in gtk2 and Qt the LM_CHANGED message is sent
>>>> before LM_SELCHANGE unlike gtk1, but gtk1 could be reimplemented
>>>> like gtk2. Under Win32 is easy to sent an extra LM_CHANGED message
>>>> in response to selection change
>>>>     
>>> It seems, there are no objections. Will you do it?
>>>   
>> Done.
>>
>> The attached patches does the following:
> 
> Thanks. Applied.
> 
>  
>> - [ComboBox] OnChange is called if a item is selected (just before
>> OnSelect)
>> - [List/ComboBox] Fix calling OnChange/Select after calls to 
>> delete/clear in gtk1/2
>> - [ListBox] Fix double call to SelectionChange after setting
>> ItemIndex (gtk2)
>> - [ComboBox] After Delete ItemIndex is -1 and Text is '' gtk1/2
>> - [ComboBox] Fix a bug that was returning previous text set through
>> Text when Style is DropDownList (GetText was returning false)
>>
>> Implementation details:
>>
>> - Under gtk1 all event handling is done inside the 'changed' event 
>> handler of the entry widget like gtk2. This event handler is now 
>> separated from the generic one. The event handler of 'select' was 
>> deleted. It also caches the LCL Index like gtk2 does.
>> - Under gtk2, the initial idea was to keep the current approach of
>> using WidgetInfo.UserData as a flag to skip unneeded event trigger,
>> but since ListBox already uses UserData (ScrollingData) was necessary
>> to move the skip logic to the ChangeLock field. The UserData of
>> ComboBox now holds the LCLIndex cache.
>> - ListBox.CreateHandle calls Assign that calls Clear, so there's no 
>> widgetinfo at this time. I added a check to widgetinfo. No big issue 
>> here, but i added some options in the comments near of it to remove
>> the check.
> 
> This creates a circle and the LCL warns about that:
> [WARNING] Recursive call to CreateWnd for ComboBox1:TComboBox while
> creating handle
> 
> Did you not see this warning?
> 
> I fixed that. Please review. 15831.

To stress this for others too...

The widgetset code should never modify any state in the LCL (except for 
events). This especially counts for CreateHandle code.

Marc




More information about the Lazarus mailing list