Code error Crashes B4A

CharlesIPTI

Active Member
Licensed User
Longtime User
ok my old VB esque skills arent great.. my first draft of this little block had a EXIT for..

this little tid-bit Crashes B4A Hard

whats the problem with this code please

B4X:
    If bLocationScanValidated = False Then
        For d = 0 To mapLocList.size - 1
            If bFoundMapLoc = False Then
                localMapLocObj = mapLocList.Get(d)
                tmpLocationNm = localMapLocObj.locNm.Trim
                If tmpLocationNm = m_localScanRetVal Then
                    m_CurrentLocationID = localMapLocObj.dbId
                    bFoundMapLoc = True
                End If
            End If
        Next
    End If


bLocationScanValidated is a global and is false on entry.

Once the work is done the local boolean bFoundMapLoc is set. In the same sub but a different code block I set the global boolean to the same value as this local boolean bFoundMapLoc ..
 

stevel05

Expert
Licensed User
Longtime User
What error are you getting and at what line? It would be helpful to post the log generated when it fails.
 
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Is mapLocList.size equal to 0...and/or what happens if it is? Seems like a -1 is possible there which could mess up code (I don't think that would mess up the FOR though unless it is trying to do a Step -1...or if B4A allows d to be used elsewhere and it is used containing a -1)). Now when you say B4A crashes though- Do you mean the IDE, the Debugger, or your app?
 
Last edited:
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
As said, more info is needed.

I would say that if you add
B4X:
d*=*mapLocList.size*-*1
To the inner If block, it would terminate the loop.
 
Upvote 0

CharlesIPTI

Active Member
Licensed User
Longtime User
OK Sorry log file attached

Thats whats Odd about it ..

I use the HTTP Util module & Service in Activity One just Fine then I go to main activity and use Http Utils again and it fails in the HttpUtil Module in the PostBytes sub where it attempts to start the service. So the error is the one from a service app has stopped unexpectedly which I cannot trap in a try catch in the HttpUtil Module...

Thanks for pointing me to the log, I forget to check that ..
it appears that the error is due to

* Activity (postmain) Create, isFirst = true **
Starting Job: GetCartState
Already working. Request ignored (GetLocMap)
Already working. Request ignored (GetLocMap)
theres 105 lines of that before
java.lang.StackOverflowError

again if I remove the call to this method the GetLocMap call to Http Util Runs just fine though !!!
 

Attachments

  • log.txt
    9.5 KB · Views: 143
Upvote 0

CharlesIPTI

Active Member
Licensed User
Longtime User
code change same error

new attempt...
B4X:
            X = 0
            If mapLocList.Size > 0 Then
               Do While X < mapLocList.Size
                   localMapLocObj = mapLocList.Get(X)
                tmpLocationNm = localMapLocObj.locNm.Trim   
                      
                         If tmpLocationNm = m_localScanRetVal Then
                         m_CurrentLocationID = localMapLocObj.dbId
                         bFoundMapLoc = True
                     End If
                           X = X +1
               Loop
            End If


and sorry it just crashes my app. and the debugger not the IDE itself
 
Upvote 0

CharlesIPTI

Active Member
Licensed User
Longtime User
Got It -- I believe---

So it wasnt the code. it was the Boolean dance I find myself forced to do for Activity_Create. I am beginning to (Obviously) overwhelm myself with boolean toggles regarding re-entry in to the Activity_Create

Thanks for pointing me wisely to the log.. when I saw the multiple calls to ValidateScannedMapLocation I just assumed something was incorrectly allowing it to re-enter activity_Create multiple Times


Thank You !!
 
Upvote 0
Top