Has anyone using the PowerBuilder Foundation Classes (PFC) experienced application crashes when an assigned dataobject is missing (either in build or development)?
We've all experienced when a dataobject is dynamically assigned and you get a blank datawindow where you expected data. This scenario is different and the PFC code crashes with null object reference in both development and compiled cases.
The scenario arises when a brand new dataobject is added to a window but for some reason TFS fails to pull down the new object to the build machine. I don't know if it is our build person not knowing what they are doing, or a TFS failure- leaning towards the latter. This is another problem- which if anyone knows the solution we'd be extremely grateful.
Since the PFC crashes in many places when a dataobject assigned to a datawindow control is missing- I'm inclined to think someone has solved this issue by fixing the PFC.
Test Case:
Datawindow control dw_1 Dataobject dw_new_dataobject which is brand new and our builder doesn't have it Code looks like dw_1.dataobject = 'dw_new_dataobject' (not dynamic assign)
What have we tried?
We've tried an IsNull(idw_requestor.object.datawindow.help.command) or IsNull(idw_requestor.object.datawindow) with no luck. Even if that did work we'd need to wrap every dot notation assignment in PFC related to datawindow property.
I should know how to solve this but drawing a blank. Is there a simple coding check we can use to verify that the assigned dataobject exists in the build, and if not handle the problem gracefully?
Ideally something like this pseudo-code:
If dw_1.databoject = 'dw_new_object' And
'dw_new_object' is nowhere to be found Then
// handle somewhat gracefully and kill the app
End If
Object: pfc_n_cst_dwsrv_sort Error: Null object reference at... in function of_setstyle of object...
PFC Code (one of many failure points):
// Check to see if the passed style number is valid.
IF IsNull(ai_style) THEN
Return -1
End If
CHOOSE CASE ai_style
CASE DEFAULT, DRAGDROP, SIMPLE, DROPDOWNLISTBOX
ii_style = ai_style
if ii_style = DEFAULT then
if isValid (idw_requestor) then
if len (idw_requestor.dataobject) > 0 then
// NULL OBJECT REFERENCE LINE BELOW when dataobject gone
idw_requestor.object.datawindow.help.command = 1
idw_requestor.object.datawindow.help.file = "pfcdlg.hlp"
idw_requestor.object.datawindow.help.typeid.setsort = "1200" idw_requestor.object.datawindow.help.typeid.setsortexpr = "800"
end if
end if
end if
Return 1
END CHOOSE
Try this:
You'll notice that datawindows which do not exist return an empty string from Describe.
Describe for an existing datawindow returns numeric values for column count and color.