Android Question List.Clear crush

Discussion in 'Android Questions' started by yaniv hanya, Aug 13, 2019.

  1. yaniv hanya

    yaniv hanya Member Licensed User

    I have this code

    Code:
    If currentFilesLst.Size>0 Then
            currentFilesLst.Clear
        
    End If
    currentFilesLst is alist of files names and has data. when it gets to the currentFilesLst.Clear
    it crush and i get this log

    it worked before and i cann't understend what hapend
    what should i chck?
     
  2. emexes

    emexes Well-Known Member Licensed User

    To diagnose the problem, try:
    Code:
    Do While CurrentFilesLst.Size > 0
        
    Log( CurrentFilesList.Get(0) )
        CurrentFilesList.RemoveAt(
    0)
    Loop
    ... and if that works (wtf?) then perhaps just delete the Log line and it's: job done!

    One possibility is that you've added the list to itself (I'm pretty sure recursion is allowed) and when that particular item is deleted, it... well, I don't know what would happen, but I'm sure there would be some complaining about it aka error message!!!

    :)
     
    Last edited: Aug 13, 2019
  3. yaniv hanya

    yaniv hanya Member Licensed User

    Thanks
    I check it right away
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    emexes likes this.
  5. yaniv hanya

    yaniv hanya Member Licensed User

    Thanks
    That explains everything.
    Everything worked fine until I decided to clear it :(
     
    emexes likes this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    In the sake of completeness, lists that are based on arrays are also read-only:
    Code:
    Dim MyList As List = Array(1234)
    MyList.Add(
    5'crash!
    Dim MyList2 As List
    MyList2.Initialize
    MyList2.AddAll(
    Array(1234))
    MyList2.Add(
    5'does not crash
     
    Xicu and emexes like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice