Skip to main content
Known Participant
April 12, 2011
Question

Strange problem in handling a notifier.

  • April 12, 2011
  • 1 reply
  • 881 views

hi,

while trying to handling the a notifier named kAIDocumentWritePreprocessNotifier( AIDocumentation.h) ----

If I copied (ctrl + c ) the content of current ai document, regardless of pasting(ctrl +v ) and closing

the application (Ai)  without saving(ctrl +s) the document, It still executing  Notify( AINotifierMessage* message )  for 2 times.

It should not execute when I am closing document with saving.

However it is not the case when no copy command is done on document.

I have checked this notifier with SDK sample and I found same problem. I tried the following code --

///////Start//////

// Register the notifier

ASErr ProjectNamePlugin::AddNotifier(SPInterfaceMessage *message)

{

     ASErr result = kNoErr;

try {

     result = sAINotifier->AddNotifier(fPluginRef, " Notifier", kAIDocumentWritePreprocessNotifier, &fNotifyHandle);

     aisdk::check_ai_error(result);

}

catch (ai::Error& ex) {

     result = ex;

}

catch(...)

{

     result = kCantHappenErr;

}

   rreturn result;

}

//Respond to the notifier

SErr ProjectNamePlugin::Notify(AINotifierMessage* message)

{

     ASErr result = kNoErr;

try

{

     if (message->notifier == fNotifyHandle)

     {

          sADMBasic->MessageAlert("inside Notifier");

          aisdk::check_ai_error(result);

     }

}

catch (ai::Error& ex) {

     result = ex;

}

catch(...)

{

     result = kCantHappenErr;

}


return result;

}

///////End//////

plz help.....

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
April 12, 2011

Sorry, I'm a little unclear on what the problem is. I think you're saying that if you subscribe to the kAIDocumentWritePreprocessNotifier you receive it twice, but only if you use CTRL+C?

I did a little testing, and it looks like you're partially right. You do get the kAIDocumentWritePreprocessNotifier twice when you quit while a document is open, but I get that twice even if I just open a document and immediately quit. If I open a document and close it immediately, I don't get the notifier. If I open a document selection something in the document, hit CTRL+C and then close the document, I get the kAIDocumentWritePreprocessNotifier but only once.


Given the documentation on the notifier, it does seem like somethign wacky is going on. I'm not sure why its being sent. The notifierData that comes with the message doesn't seem to include the document handle (unlike other document related notifiers) so you can't use that. I think your best bet is to track other notifiers, like kAIMetadataSyncNotifier, which is sent before a save. If you don't see that, I think you're safe to ignore the kAIDocumentWritePreprocessNotifier.

Doug Habben
Known Participant
September 20, 2014

I came across this while having trouble updating artwork before a document save using kAISaveCommandPreNotifierStr.

The notifier does not seem to be sent when the user clicks Save in the "Do you want to Save?" dialog when closing a modified document. That is, it only seems to be sent when the Save is invoked from a menu command.

kAIMetadataSyncNotifier gets sent in both cases though and solved my problem. Thank-you very much A. Patterson.