Can this give an OutOfBoundsException?

This comes from the documentation on PopupMenu:

[quote]Displaying the RowTag of the selected menu item:

TexField1.Text = PopupMenu1.RowTag(PopupMenu1.ListIndex) [/quote]

Can this code, above, ever generate an OutOfBoundsException, provided that the popup contains at least one item? My code, in the Action of a button, checks that the ListIndex is not < 0 before asking for the RowTag, and yet a user’s log has this:

[quote]17 Jan 2019 15:28:17 FATAL: Stack: RuntimeRaiseException
17 Jan 2019 15:28:17 FATAL: RaiseOutOfBoundsException
17 Jan 2019 15:28:17 FATAL: RuntimeComboBoxGetRowTag
17 Jan 2019 15:28:17 FATAL: PopupMenu.RowTag%v%oi8
17 Jan 2019 15:28:17 FATAL: Prefs.Prefs.acctscheckButton_Action%%o<Prefs.Prefs>o
17 Jan 2019 15:28:17 FATAL: Delegate.IM_Invoke%%o
17 Jan 2019 15:28:17 FATAL: AddHandler.Stub.15%%
[/quote]

Comments welcome.

the listindex can be -1 if there is no selection
and rowtag(-1) gives outofbound…

What PopupMenu1.RowTag(PopupMenu1.ListIndex) is supposed to be holding (Type and Value) ?

Also: you may have forgotten to add a Return in the if block where you test PopupMenu1.ListIndex is not < 0 (this depends on how you wrote the if Block).

Here is the actual code (the entire code of the button’s action event):

[code]dim absid as integer, acctname as text

prefsmsg (acctsmsgarea)

if (acctssel.ListIndex<0) then
prefsmsg (acctsmsgarea, “No account available to test with”, “red”)
return
end if

if (rcvThread<>Nil) then
prefsmsg (acctsmsgarea, “Receive test already running”, “red”)
return
end if

absid = acctssel.RowTag(acctssel.ListIndex)
acctname = acctssel.Text.ToText

rcvThread = new taskClass (absid, acctname)
AddHandler rcvThread.run, WeakAddressOf rcvtester
AddHandler rcvThread.UIupdater, WeakAddressOf writeUI
AddHandler rcvThread.killed, WeakAddressOf rcvTidy

rcvThread.run ()

[/code]

The code that populates the PopupMenu forces an item to be showing , unless there are none.

Under macOS HS, and under Win7 Home Premium SP1 running in a VM, I can’t make this fail.

Both versions built on my Mac with 2018R4. The user is running Win7 Home Premium SP1. Is this likely to be a “Universal Runtime” issue?

choose a line in the popup, but before releasing the mouse button, put the mouse pointer outside the popup.
it should get a listindex=-1 and fail the method.

If listindex is -1 I output the “No account available to test with” message. When the popup is loaded, the user’s default account (or the first entry) is shown by explicitly setting listindex.

Hi Tim. Can you upload a really simple demo showing the controls in use and how you’re opening the popup and consuming the click etc? Cheers