Bug? App hangs when using colon :

Russ J

Member
If think this is a bug. I am building using B4A 10.0, Android 9, Samsung Galaxy Tab Active2, portrait orientation

Summary
This line of code causes the program to hang. It may process a few more lines of UI related code, but it will eventually freeze. For this example, Result = true.
Bad code:
    wait for (Method2) Complete (Result As Boolean) :    If Not(Result) Then Return

Refactoring it into these two lines of code resolves the issue.
Good code:
    wait for (Method2) Complete (Result As Boolean)
    If Not(Result) Then Return

Complete sample:
#Region  Project Attributes
 Sub Process_Globals
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume
    CallSubDelayed(Me, "Method_BAD")  'Change this to either Method_OK or Method_BAD to illustrate the bug.
End Sub

Sub Button1_Click
    ToastMessageShow("Hello world!", False)
End Sub

Sub Method_OK()
    wait for (Method2) Complete (Result As Boolean)
    If Not(Result) Then Return
End Sub

Sub Method_BAD
    wait for (Method2) Complete (Result As Boolean) :    If Not(Result) Then Return
End Sub

Sub Method2() As ResumableSub
    Return True
End Sub

Small example project attached. When using the "bad" code, the button on the layout is never displayed...essentially the UI thread is hung.
 

Attachments

  • test.zip
    10.5 KB · Views: 276

Russ J

Member
Maybe the compiler could be improved to indicate any incorrect use prior to compilation, as I spent hours trying to figure out why my program was hanging.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…