Skip to main content
arge1234
Known Participant
April 29, 2016
Answered

Wrong clientdata pointer in callback function

  • April 29, 2016
  • 5 replies
  • 2148 views

Hello,

I am trying to pass a data object to a callback function when a document loads.

This is my code:

  AVAppRegisterNotification(AVDocDidOpenNSEL, gExtensionID, ASCallbackCreateNotification(AVDocDidOpen, (void*)myNotificationCallback), (void*)&aClientData);

The callback function is as follows:

ACCB1 void ACCB2 myNotificationCallback(void *clientData)

{

....

}

However my clientData pointer address in the callback function is not the same as the address when I  put it in the AVAppRegisterNotification function.

How is this possible ?

This topic has been closed for replies.
Correct answer Test Screen Name

Consider, for example: the callback will need to know which AVDoc is just opened, which is not possible if the only parameter is clientData.

5 replies

Test Screen NameCorrect answer
Legend
May 4, 2016

Consider, for example: the callback will need to know which AVDoc is just opened, which is not possible if the only parameter is clientData.

arge1234
arge1234Author
Known Participant
May 4, 2016

Thank you, it must be these 3 ones:

AVDoc myDoc, ASInt32 error, void *clientData

Legend
May 4, 2016

Please refer to the documentation or header files for the correct 3 parameters for an AVDocDidOpen callback.

Legend
May 4, 2016

I think we have the explanation. You have the wrong number of parameters. Each callback has different parameters and you must be correct.

arge1234
arge1234Author
Known Participant
May 4, 2016

Could you please tell me where I miss some parameters ?

Legend
May 4, 2016

I understand your reasoning; it is probably correct. So, please post the function declaration for myNotificationCallback (the actual contents are not important, just the declaration).

arge1234
arge1234Author
Known Participant
May 4, 2016

That is this:

extern ACCB1 void ACCB2 myNotificationCallback(void *clientData);


And for the callback that works correctly:

extern ACCB1 void ACCB2 MyPluginCommand(void *clientData);

Bernd Alheit
Community Expert
Community Expert
April 29, 2016

What do you use as aClientData ?

arge1234
arge1234Author
Known Participant
April 29, 2016

I made a class CclientData and I want to pass this through.

Bernd Alheit
Community Expert
Community Expert
April 29, 2016

Did you create an instance of this class?