1. Glenn Barber
  2. PowerBuilder
  3. Tuesday, 28 March 2023 22:32 PM UTC

We have PB Response Selection window that sometimes crashes with a Null Object Reference (PB17)

The window has a Event which does A Retreval on the main datawindow (dw_1) using the entry in a sle

User Selects a Row - presses Ok and the Default window event grabs the value from the selected row and returns to the calling window with return.

It appears that sometimes - if the user types quickly after already selecting a row,  that the Retrieve Process is initiated while the window is being closed and the retrun from the retieve process falls into code which fails because the datawindow control pointer is no longer valid.

Ive tried to trap this with the Valid test

IF NOT isValid(dw_1) THEN RETURN

But the program still crashes with an Null Object Reference on this statement.

Any ideas whats going on and how I can avoid the crash

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 29 March 2023 02:54 AM UTC
  2. PowerBuilder
  3. # 1

Hi,

Try using IsValid(...) on the window that holds the dw_1.

You say you "return to the calling window with RETURN". I hope that is CloseWithReturn() ?

regards.

Comment
  1. Glenn Barber
  2. Wednesday, 29 March 2023 03:03 AM UTC
Yes Close with return.



As this is in the Reponse Windows Event Script - are you suggesting I use IF IsValid(this)?

Whats odd is that I have code in the window executing where the window is already being shut down. Yields don't seem to make a difference.

I imagine there is a close going on - as this is in the pfc - perhaps there is some variable set at the window that I can test.

  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 29 March 2023 03:10 AM UTC
From where (which event), do you close the window with CloseWithReturn() ?

I have to check in several places (in the Close() event) if the window is still really valid or not. Can't remember exactly why, but it has happened to me in certain circumstances.

  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 29 March 2023 03:13 AM UTC
I think we also have some variable ib_closingWindow somewhere. Tomorrow I'll have a look, but can't promise anything. Very busy and right now it's 03:13 AM, gonna get 3 hours of sleep.

regards.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.