Bug? List bug - uninitialised list incorrectly reported - its a bit complicated but look closely at the example.

JackKirk

Well-Known Member
Licensed User
Longtime User
This started out on:
https://www.b4x.com/android/forum/threads/solved-maddening-list-bug.134405/

The following example needs to be looked at closely:
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Public good_list As List
    Public good_value As String
    Public bad_list As List
    Public bad_value As String
    Public obj_timer As Timer
End Sub

Sub AppStart (Args() As String)
    good_list.Initialize
    good_value = "good"
    good_list.Add(good_value)
 
    obj_timer.Initialize("event_obj_timer", 1)
    obj_timer.Enabled = True
 
    StartMessageLoop

End Sub

Sub event_obj_timer_Tick
    obj_timer.Enabled = False
 
    Log(good_list.IsInitialized)
 
    Sleep(1)
 
    If good_list.Get(0) = "whatever" Then                 '<<<<<<This is line 34 which is reported as bombing
 
    End If
 
    If bad_list.Size > 0 Then                            '<<<<<<This is the real problem
        Log("???")
    End If

End Sub
The log is:
Note: the error is reported as on line 34 but is actually on line 38

Sounds trivial? - not when you are dealing with a larger bit of code and the distance between reported and actual is considerable.

Everything is reported properly when the sleep statement is removed - so it is to do with resumable subs.

I should add that I tried it with maps too - with the same problem.
 

Attachments

  • listbug.zip
    893 bytes · Views: 213
Cookies are required to use this site. You must accept them to continue using the site. Learn more…