PowerBuilder (PFC) Crash Referencing Datawindow Property - When TFS Not Pulling Dataobject

624 views Asked by At

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
2

There are 2 answers

1
Eric Glenn On BEST ANSWER

Try this:

string ls_rc
datastore lds_test

lds_test = create datastore

lds_test.dataobject = "ThisIsReallyNotDatawindowName"
ls_rc = lds_test.Describe("DataWindow.Column.Count") // Returns ""
ls_rc = lds_test.Describe("DataWindow.Color") // Returns ""

lds_test.dataobject = "dw_import" // Use the name of an existing datawindow.
ls_rc = lds_test.Describe("DataWindow.Column.Count") // Returns arbitrary number
ls_rc = lds_test.Describe("DataWindow.Color") // Returns arbitrary number

destroy lds_test

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.

2
Matt Balent On

I have experienced this same behavior in TFS. The only way I was satisfied that new objects could be pulled from TFS to my local machine was to manually verify.

The process we used was to notify all team members when new objects were added to source control (this was the responsibility of the developer who created the new object).
I would then refresh my workspace from TFS then go to each pbl which was added to.
If the object was missing I would then create a 'stub' object manually of the same type (datawindow object, nvo, etc.) then refresh again. This would normally pull the source from TFS down to my local machine.