From 42005272a99892f7b3351d545adfb3abc208d8a6 Mon Sep 17 00:00:00 2001 From: gambas Date: Thu, 8 Jul 2021 23:12:39 +0200 Subject: [PATCH] ListEditor: Fix crash when checking for duplicates if the Unique property is TRUE. [GB.FORM] * BUG: ListEditor: Fix crash when checking for duplicates if the Unique property is TRUE. --- comp/src/gb.form/.project | 4 +- .../gb.form/.src/ListEditor/FListEditor.class | 2 +- .../gb.form/.src/ListEditor/ListEditor.class | 2 +- .../gb.form/.src/Test/FTestListEditor.class | 6 +++ .../gb.form/.src/Test/FTestListEditor.form | 1 + comp/src/gb.form/.src/Test/FTestMaskBox.class | 50 +++++++++---------- comp/src/gb.form/.src/Test/FTestMaskBox.form | 3 +- 7 files changed, 37 insertions(+), 31 deletions(-) diff --git a/comp/src/gb.form/.project b/comp/src/gb.form/.project index c73c3b8ac..5de68161e 100644 --- a/comp/src/gb.form/.project +++ b/comp/src/gb.form/.project @@ -1,6 +1,6 @@ # Gambas Project File 3.0 Title=More controls for graphical components -Startup=FTestValueBox +Startup=FTestMaskBox Icon=.hidden/icon.png Version=3.16.90 VersionFile=1 @@ -10,7 +10,7 @@ Component=gb.form Component=gb.settings Component=gb.form.stock Authors="Benoît Minisini" -Environment="GB_GUI=gb.qt5\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive" +Environment="GB_GUI=gb.gtk3\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive" TabSize=2 Translate=1 Language=en diff --git a/comp/src/gb.form/.src/ListEditor/FListEditor.class b/comp/src/gb.form/.src/ListEditor/FListEditor.class index 3556e036d..9fc424694 100644 --- a/comp/src/gb.form/.src/ListEditor/FListEditor.class +++ b/comp/src/gb.form/.src/ListEditor/FListEditor.class @@ -298,7 +298,7 @@ Private Sub CheckUnique() I = 1 While I < lstData.Count - iPos = lstData.Find(lstData[I]) + iPos = lstData.Find(lstData[I].Text) If iPos <> I Then lstData.Remove(I) Else diff --git a/comp/src/gb.form/.src/ListEditor/ListEditor.class b/comp/src/gb.form/.src/ListEditor/ListEditor.class index 1c27677a8..e29bedf4e 100644 --- a/comp/src/gb.form/.src/ListEditor/ListEditor.class +++ b/comp/src/gb.form/.src/ListEditor/ListEditor.class @@ -18,7 +18,7 @@ Property Read Editor As Control '' Return or set if duplicates are allowed in the list. '' -'' By default, this property is 'FALSE' and duplicate are allowed. +'' By default, this property is 'FALSE' and duplicates are allowed. Property Unique As Boolean '' Return or set the index of the current item. diff --git a/comp/src/gb.form/.src/Test/FTestListEditor.class b/comp/src/gb.form/.src/Test/FTestListEditor.class index d1a0767db..e887a34b6 100644 --- a/comp/src/gb.form/.src/Test/FTestListEditor.class +++ b/comp/src/gb.form/.src/Test/FTestListEditor.class @@ -6,3 +6,9 @@ Public Sub ListEditor1_Select() Debug End + +Public Sub Form_Open() + + ListEditor1.Index = 20 + +End diff --git a/comp/src/gb.form/.src/Test/FTestListEditor.form b/comp/src/gb.form/.src/Test/FTestListEditor.form index 63bdac1ae..33be7748b 100644 --- a/comp/src/gb.form/.src/Test/FTestListEditor.form +++ b/comp/src/gb.form/.src/Test/FTestListEditor.form @@ -4,6 +4,7 @@ MoveScaled(0,0,64,64) { ListEditor1 ListEditor MoveScaled(5,6,48,34) + List = [("Élément 1"), ("Élément 2"), ("Élément 3"), ("Élément 4"), ("Élément 5")] Unique = True } } diff --git a/comp/src/gb.form/.src/Test/FTestMaskBox.class b/comp/src/gb.form/.src/Test/FTestMaskBox.class index e10096aaf..abd5da9bd 100644 --- a/comp/src/gb.form/.src/Test/FTestMaskBox.class +++ b/comp/src/gb.form/.src/Test/FTestMaskBox.class @@ -13,28 +13,28 @@ Public Sub Button1_Click() End -Public Sub MaskBox1_Validate() - - Dim aAdr As String[] - Dim I As Integer - Dim sAdr As String - Dim iAdr As Integer - Dim bValid As Boolean - - aAdr = Split(Last.Text, ".") - If aAdr.Count = 4 Then - For I = 0 To aAdr.Max - bValid = False - sAdr = Trim(aAdr[I]) - If sAdr Then - Try iAdr = CInt(sAdr) - If Error Then Break - If iAdr < 0 Or If iAdr > 255 Then Break - Endif - bValid = True - Next - Endif - - If Not bValid Then Stop Event - -End +' Public Sub MaskBox1_Validate() +' +' Dim aAdr As String[] +' Dim I As Integer +' Dim sAdr As String +' Dim iAdr As Integer +' Dim bValid As Boolean +' +' aAdr = Split(Last.Text, ".") +' If aAdr.Count = 4 Then +' For I = 0 To aAdr.Max +' bValid = False +' sAdr = Trim(aAdr[I]) +' If sAdr Then +' Try iAdr = CInt(sAdr) +' If Error Then Break +' If iAdr < 0 Or If iAdr > 255 Then Break +' Endif +' bValid = True +' Next +' Endif +' +' If Not bValid Then Stop Event +' +' End diff --git a/comp/src/gb.form/.src/Test/FTestMaskBox.form b/comp/src/gb.form/.src/Test/FTestMaskBox.form index 570b8c58b..36cf0f641 100644 --- a/comp/src/gb.form/.src/Test/FTestMaskBox.form +++ b/comp/src/gb.form/.src/Test/FTestMaskBox.form @@ -8,7 +8,6 @@ } { MaskBox1 MaskBox MoveScaled(13,34,24,4) - Mask = "###<.###<.###<.###<" - Prompt = MaskBox.Bracket + Mask = "####0