From 116d6521cfb405e82d65cab5386fb1bab72ef783 Mon Sep 17 00:00:00 2001 From: marc Date: Wed, 29 Mar 2006 19:21:18 +0000 Subject: [PATCH] * Fixed setting itemindex=-1 without handle * Fixed selchange events during combo destoy git-svn-id: trunk@9043 - --- lcl/include/customcombobox.inc | 26 ++++++++++++++------------ lcl/interfaces/gtk/gtkobject.inc | 5 +++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lcl/include/customcombobox.inc b/lcl/include/customcombobox.inc index bc9e5cbd79..e8483551f9 100644 --- a/lcl/include/customcombobox.inc +++ b/lcl/include/customcombobox.inc @@ -789,21 +789,23 @@ procedure TCustomComboBox.SetItemIndex(Val : integer); begin //if CompareText(Name,'TextToFindComboBox')=0 then // debugln('TCustomComboBox.SetItemIndex A ',DbgSName(Self),' Text="',Text,'"'); - if Val=GetItemIndex then exit; - if (Val>=Items.Count) and (not (csLoading in ComponentState)) then exit; + if Val = GetItemIndex then exit; + if Val < -1 then Exit; + if (Val >= Items.Count) and (not (csLoading in ComponentState)) then exit; FItemIndex:= Val; - if not (csLoading in ComponentState) then begin - //if (FItemIndex>=0) and (not (csLoading in ComponentState)) then - // Text:=FItems[FItemIndex]; - if HandleAllocated then begin - TWSCustomComboBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex); - Select; - end else begin - // remember text, in case one reads text without creating handle - Text := FItems.Strings[FItemIndex]; - end; + if csLoading in ComponentState then Exit; + + if HandleAllocated then begin + TWSCustomComboBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex); + Select; + end else begin + // remember text, in case one reads text without creating handle + if Val = -1 + then Text := '' + else Text := FItems.Strings[FItemIndex]; end; + //if CompareText(Name,'TextToFindComboBox')=0 then // debugln('TCustomComboBox.SetItemIndex END ',DbgSName(Self),' Text="',Text,'"'); end; diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index a523bebb1e..8b2b56c24b 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -4143,7 +4143,12 @@ begin // childs if GtkWidgetIsA(Widget,GTK_COMBO_GET_TYPE) then begin + g_signal_handlers_destroy(PGtkObject(PGtkCombo(Widget)^.Entry)); + g_signal_handlers_destroy(PGtkObject(PGtkCombo(Widget)^.List)); SetComboBoxText(PGtkCombo(Widget),nil); + + // MWE: + // TODO: Check: Why is there widgetinfo on subwidgets ??? FreeWidgetInfo(PGtkCombo(Widget)^.Entry); FreeWidgetInfo(PGtkCombo(Widget)^.Button); end;