LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Unreleased PropertyObjects at Engine Shutdown - how to get rid of ?

Now, I finished my own TestStand UI with Labwindows/CVI I have one persistent problem when shutting down the Engine.
I studied this forum for solutions, but what I found didn't solve the problem, even didn't change it.
After I tried a couple of ideas for days, I'm running out of now. I'm beginning to think the problem isn't on my side.
So, I need help to get through this or around. Any suggestions are welcome !

Here some informations...

I always get this message on terminating the Engine:

-------------------------------------------------------------------------------
References to PropertyObjects were not released properly.
    Total number of objects: 4938
    Number of top-level objects: 51

    Note: Some top-level objects may be included if they are referenced by
    an incorrectly released top-level object. For example, an unreleased
    SequenceContext object references a SequenceFile object.

    The following top-level objects were not released:

        Sequences [1 object(s) not released]
            Sequence #1:
                Name: Single Pass

        Type Definitions [29 object(s) not released]
            Type Definition #1:
                Name: UUT

-------------------------------------------------------------------------------

TestSequence is started this way:
TS_SeqFileGetSequenceByName(ModelFileObj, &errorInfo, "Single Pass", &SequenceObj);
if (SequenceObj != 0) {
  TS_EngineNewEditArgs(hEngine, &errorInfo, &EditArgsObj);
  if (EditArgsObj != 0) {
    TS_EditArgsSetSelectedSeqFile(EditArgsObj, &errorInfo, SequenceObj);
    errChk(CA_GetInterfaceFromObjHandle(EditArgsObj, &IID_IDispatch, 0, &EditArgsPtr, NULL));
    EditArgsParam = CA_VariantDispatch(EditArgsPtr);
    tsErrChk(TS_EngineNewExecution(hEngine, &errorInfo, TestSeqObj, "Single Pass",
             ModelFileObj, VTRUE, TS_ExecTypeMask_Normal|TS_ExecTypeMask_NotRestartable, CA_DEFAULT_VAL,
             EditArgsParam, CA_DEFAULT_VAL, &ExecutionObj));
    ....
    tsErrChk(TS_ExecutionAddPostStepCustomUIMessage(ExecutionObj, &errorInfo, TS_UIMsg_PostStep, "True",
             TS_CustomUIMsgOptions_AppliesToAllThreads));
    tsErrChk(TS_ExecutionGetForegroundThread(ExecutionObj, &errorInfo, &ThreadObj));
There is no problem starting it without a ProcessModel this way:
tsErrChk(TSUI_SequenceFileViewMgrRun(hSequenceFileViewMgr, &errorInfo, CA_DEFAULT_VAL, &ExecutionObj));
But this is only a fallback and I need the ProcessModel.

..and terminated this way (some steps may have the same sense-this is a result of trying):
tsErrChk(TSUI_ExecutionViewMgrTerminateExecution(hExecutionViewMgr, &errorInfo));
tsErrChk(TS_EngineAbortAll(hEngine, &errorInfo));
tsErrChk(TS_EngineTerminateAll(hEngine, &errorInfo));
tsErrChk(TSUI_ApplicationMgrCloseAllExecutions(hApplicationMgr, &errorInfo));

Before shutting down the Engine all objects will be released like that (in the reverse order of creation):
if (hSequenceContext) CA_DiscardObjHandle(hSequenceContext);
if (CommandObj) CA_DiscardObjHandle(CommandObj);
if (ThreadObj) CA_DiscardObjHandle(ThreadObj);
if (EditArgsObj) CA_DiscardObjHandle(EditArgsObj);
if (TestSeqObj) {
  error = TS_SeqFileGetCanUnload(TestSeqObj, &errorInfo, &ok);
  error = TS_SeqFileUnloadModules(TestSeqObj, &errorInfo, &unloaded);
  error = TS_EngineReleaseSeqFileEx(hEngine,&errorInfo,TestSeqObj,
         TS_ReleaseSeqFile_UnloadFileIfModified|TS_ReleaseSeqFile_DoNotRunUnloadCallback|TS_ReleaseSeqFile_UnloadFile, &removed);
  error = TSUI_ApplicationMgrCloseSequenceFile(hApplicationMgr, &errorInfo, TestSeqObj, &closed);<<< Is closed properly
  error = CA_DiscardObjHandle(TestSeqObj);
}
if (SequenceObj) {
  error = TS_SequenceUnloadModules(SequenceObj, &errorInfo, &unloaded);
  error = CA_DiscardObjHandle(SequenceObj);
}

Next section won't close the SequenceFile, although it say CanUnload=ok:
TSUI_ApplicationMgrOpenSequenceFile(hApplicationMgr, &errorInfo, filename, &TestSeqObj);
TS_SeqFileGetModelSeqFile(TestSeqObj, &errorInfo, &ModelDescription, &ModelFileObj);
if (ModelFileObj) {
  TS_SeqFileGetCanUnload(ModelFileObj, &errorInfo, &ok);
  TS_SeqFileUnloadModules(ModelFileObj, &errorInfo, &unloaded);
  TS_EngineReleaseSeqFileEx(hEngine,&errorInfo,ModelFileObj,
               TS_ReleaseSeqFile_UnloadFileIfModified|TS_ReleaseSeqFile_DoNotRunUnloadCallback|TS_ReleaseSeqFile_UnloadFile,
               &removed);
  TSUI_ApplicationMgrCloseSequenceFile(hApplicationMgr,&errorInfo,ModelFileObj,&closed);  <<< always DISP_E_EXCEPTION
  CA_DiscardObjHandle(ModelFileObj);

TSUI_ApplicationMgrGetExecutions(hApplicationMgr, &errorInfo, &hExecutions);
TSUI_ExecutionsGetNumIncomplete(hExecutions, &errorInfo, &num);  <<< always 0
TSUI_ExecutionsGetNumPaused(hExecutions, &errorInfo, &num);       <<< always 0
TSUI_ExecutionsGetNumRunning(hExecutions, &errorInfo, &num);     <<< always 0
if (hExecutions) CA_DiscardObjHandle(hExecutions);

Finally, the Engine will be shut down:
    CA_DiscardObjHandle(hEngine);    <<< this brings up the popup
    CA_DiscardObjHandle(hApplicationMgr);
Additionally, I use the ApplicationMgr->DisplayExecution Event and changed it like it was adviced in the LabView solution (which was my great hope but didn't change anything):

HRESULT CVICALLBACK ApplicationMgr_OnDisplayExecution(...)
{
    TSUIObj_Execution exec = 0;
    switch (reason) {
      ...
    }
    // get old execution and release it...
    TSUI_ExecutionViewMgrGetExecution(hExecutionViewMgr, &errorInfo, &exec);  <<< hExecutionViewMgr is a global RefHandle
    if (exec) CA_DiscardObjHandle(exec);     <<< I wonder what to do here. Creating an object and destroying it doesn't make sense.
    
    // set the current execution to be the new execution
    TSUI_ExecutionViewMgrSetByRefExecution(hExecutionViewMgr, &errorInfo, execution);

    // finally always release execution object
    if (execution) CA_DiscardObjHandle(execution);
}

... and those Events, too :
ApplicationMgr_OnDisplaySequenceFile(...);
ApplicationMgr_OnDisplayExecution(...);
ApplicationMgr_OnUIMessageEvent(...);
ApplicationMgr_AfterUIMessageEvent(...);
ApplicationMgr_OnExitApplication(...);
ExecutionViewMgr_OnRunStateChanged(...);
ExecutionViewMgr_OnEndExecution(...);

If there is no solution to that, is there a workaround to get rid of this $%§& popup ?
The Popup says my debug settings are configured to show this information, but where can I change it ?!

By the way, the TestSequence file is as simple as possible - just 2 lines changing local variables.

Huu, this was a lot of stuff - sorry.
0 Kudos
Message 1 of 4
(3,949 Views)

Hi,

Looking at the way you obatin your reference to the Model Process, I dont think this is the correct way.

You should get a reference to the SequenceFile you want to open, which would be the TestSequence file, then use this reference to get a reference to the Process Model sequence file by using TS_SeqFileGetModelSeqFile(). If the sequencefile you have opened has a Process Model SequenceFile associated with it then you can use the SequenceFile Object reference returned. If no Process Model associated with your Test Sequence File, you can only run the Sequences in the TestSequence file without the Process Model. eg "Run MainSequence"

You can then plug this into your NewExecution along with  all the other references and the "Single Pass" name of the sequence  to run.

I dont think you should be obtaining you reference to the Process Model by using the TS_SeqFileGetSequenceByName().

Any I shall keep looking.

Regards Ray Farmer

Regards
Ray Farmer
Message 2 of 4
(3,923 Views)

Hi (again),

Although this is CVI, its mainly a TestStand function and it would have been better to post this in the TestStand forum.

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 3 of 4
(3,921 Views)
Hi Ray,

thank you very much for your help and the time you take to analyse all this stuff !

I did it the way you mentioned (unfortunately, I forgot to post the first lines of execution initialization):
tsErrChk(TSUI_ApplicationMgrOpenSequenceFile(hApplicationMgr, &errorInfo, filename, &TestSeqObj));
ModelFileObj = 0;
TS_SeqFileGetModelSeqFile(TestSeqObj, &errorInfo, &ModelDescription, &ModelFileObj);
if (ModelFileObj == 0) TS_EngineGetStationModelSeqFile(hEngine, &errorInfo, &ModelDescription, &ModelFileObj);
if (ModelFileObj != 0) { ...
Next step is to prepare the TS_EngineNewExecution. My fault was to think it needs an EditArgsObj. I simply removed it with all the preparation before and...it works !!!

This is the solution ! Thank you so much.

Regards,
Thomas

P.S.: you're not right - it was best placed here 😉
0 Kudos
Message 4 of 4
(3,908 Views)