P3D::PdkServices::GetEventService()->UnregisterCallback

BenBaron
Posts: 79
Joined: Fri Jan 16, 2015 7:51 am

P3D::PdkServices::GetEventService()->UnregisterCallback

Postby BenBaron » Tue Nov 13, 2018 1:28 pm

Hi all,

the above call doesn't seem to be implemented correctly. It seems to register the Callback again, instead of unregistering. At least, it is increasing the refCount on the Callback, instead to decreasing it. Also, the description and function paramater list in IEventService.h is the same as with P3D::PdkServices::GetEventService()->RegisterCallback, so something is definitely amiss there.

Greets, Benny

BenBaron
Posts: 79
Joined: Fri Jan 16, 2015 7:51 am

Re: P3D::PdkServices::GetEventService()->UnregisterCallback

Postby BenBaron » Thu Dec 20, 2018 12:36 pm

Hi guys,

with the newest SDK 4.4.16.27106 I am still experiencing shomething odd with this method: although the UnregisterCallback method "seems" to unregister the callback (at least P3D doesn't show an API.dll crash on exit in EventViewer anymore), it is increasing the refCount on the callback. Thus, it's destructor won't get called when I assign the callback's CComPtr to nullptr.

Of course, this isn't of much priority, but just for the sake of knowledge I'd like to know what is going on there as it works as expected with UnRegisterVisualEffectCallback() and UnregisterCallback() methods effectively reducing the refCount of the referenced instances.

Greets, Benny

Pop
Posts: 324
Joined: Sun Jul 29, 2012 8:20 pm

Re: P3D::PdkServices::GetEventService()->UnregisterCallback

Postby Pop » Thu Dec 20, 2018 1:15 pm

What a/c are included?

User avatar
Rob McCarthy
Lockheed Martin
Posts: 2758
Joined: Wed Aug 24, 2011 1:37 pm

Re: P3D::PdkServices::GetEventService()->UnregisterCallback

Postby Rob McCarthy » Thu Dec 20, 2018 1:53 pm

Hello,

The CameraSystemPDK and DataHarvester samples both use the event service. Does your setup differ from these? If so can you post a small code sample showing the problem?

Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead

BenBaron
Posts: 79
Joined: Fri Jan 16, 2015 7:51 am

Re: P3D::PdkServices::GetEventService()->UnregisterCallback

Postby BenBaron » Thu Dec 20, 2018 3:25 pm

Hi Rob,

took a look at the CameraSystemPDK sample and this is quite similar to what I am doing.

Like me, it is using the call to:

Code: Select all

PdkServices::GetEventService()->UnregisterCallback(EVENTID_Message, this);
if messageID == EVENT_MESSAGE_APPLICATION_SHUTDOWN.

This should normally decrease the refCount on the s_pSystemReadyCallback, so that when

Code: Select all

s_pSystemReadyCallback = nullptr;


in void __stdcall DLLStop(void) is called, refCount would reach 0 and the s_pSystemReadyCallback's destructor would be called on its deletion.

And although I didn't test the sample, this isn't happening in my code, as UnregisterCallback() increases the refCount, instead of decreasing it, so on assigning nullptr to s_pSystemReadyCallback I'd expect a remaining refCount of 2. Of course, as the sim exits anyway this isn't much of a problem, but the callback isn't deleted this way. And this might impose problems if someone was trying to UnregisterCallback() and not closing the sim as it was still in memory somewhere.

Nevertheless, I wanted to find out if this is normal behaviour or if this might be a bug.

Thanks for your help.

Benny


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 7 guests