WebTimer.CallLater Nil Object Exception

@Thom_McGrath - yup. See my second post. I think the docs could be clearer here.

Exactly. I think it’s confusing. Probably meant to be convenient? But arguably it’s just misleading.

1 Like

Bad design on Xojo’s end. Having a timer call that is to be happening later has no use case to cause an error internally (unable to be catched logically). The error should be catched by xojo, Ignored and the call address should be removed as it would be when it was called. Why would anyone use WeakAddressOf if it was to be causing an error (and therefore any closed control to catch you in the back)?

There is no use to have an exception there other than to cause havok. For this NilObjectException. It’s only useful if xojo had an operator like

Timer.CallLater( 100, Weakaddressof? Somemethod )

To skip if it was nil, some other languages have this “?”

Probably calls into the Session if ther was any. At least that is what the logic should be in my view.

We’re going down the wrong rabbit hole, I think.
Is there a ticket for the real problem of WebDataSource locking up?

I am using AWS Aurora (MySQL 8 compatible) with MBS SQL plugin, but the data isn’t being loaded directly from a RowSet, etc.

The data is pre-fetched into an array of objects which is iterated through to load the data source.

So the classes here are:

  • RowDataObject
  • ListRowDS (implements WebDataSource)

ListRowDS’ Constructor takes an array of type RowDataObject as its only param.

The method in question (the one being invoked by Timer.CallLater) creates a new instance of ListRowDS and sets the datasource property of the WebListbox:

Private Sub loadApplications(RDArray() as RowDataObject)
 
    select case Session.userRoleID
    case Settings.roleAdmin
      self.projects_list.RowSelectionType = WebListBox.RowSelectionTypes.Multiple
      
    end select

    If RDArray.LastIndex >= 0 Then
      dim ds as new ListRowDS(RDArray)
      self.ProjectList.Datasource = ds
      
    else
      self.ProjectList.DataSource = Nil
      self.ProjectList.RemoveAllRows
      self.ProjectList.NoRowsMessage = "No Data Found"
      
    end if
  
  Return
  
End Sub

that’s it.

I think this only happens to Admin users (they’re the only ones who have reported it) and looking at the code, they’re the only users where RowSelectionTypes.Multiple is set.

Do your WebListBoxes allow selecting multiple rows.

That being said, introducing just a little delay has made this problem go away for them. so
???

1 Like

Back to the original topic for a sec, what you could do instead is use a messaging queue and have callLater call that. The messaging queue would hold the weak addresses and could then check if the target was nil before calling it.

1 Like

@Greg_O - Appreciate the thought.

I do similar for other functions in the app and may go that route.

The “real” original issue was the WebListbox “misbehaving” when being used with a data source; it’s what prompted my use (aka abuse :upside_down_face:) of WebTimer.CallLater in the first place.

For now, I’ve added some extra data points and logging (as this hasn’t happened in the last two days) to see if I can “catch the exception in the act”.

What I’d like is for the WebListBox to never get “hung” showing the processing message until you refresh the list either by fixing an error on my part or helping discover and fix a bug in the Web Framework.

–

EDIT - Apparently I forgot the topic of my own thread (:grimacing:). I do consider this “solved” by Thom as I was just misunderstanding what WebTimer.CallLater does.

Anthony

About Timer vs WebTimer. Timer.CallLater isn’t session aware, while WebTimer.CallLater is.

The idea is to be able to modify things without having to store the session identifier somewhere and having to restore the session context before modifying a WebLabel, for example, that lives inside a session.

Here is a sample project. Timer.CallLater won’t work, WebTimer.CallLater will be able to update the label without additional work:

CallLater.xojo_binary_project.zip (8.9 KB)

1 Like