Skip to main content
Known Participant
February 17, 2015
Question

setup dictionary after save as

  • February 17, 2015
  • 1 reply
  • 1027 views

Hello everyone,

I try to fill some document dictionary values after a "save as" action, and that fails.

My process (CS5 yes CS5!, Windows):

- open a template OK

- save as document (new name and location) via actions OK

- add artboards OK

- fill dictionary values FAIL (even skips the instruction in the debugger)

Exception non gérée à 0x008D74B1 dans Illustrator.exe : 0xC0000005 : Violation d'accès lors de l'écriture à l'emplacement 0xE032B50E.

when executing :

AIDictionaryRef    theDictionary = NULL;
sAIDocument->GetDictionary(&theDictionary);

Any clue? is there a current document after a save as action?

Thanks

Christian

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
February 17, 2015

Maybe its a timing thing. Where are you doing the dictionary saving? Are you reacting to a notifier? If not, try responding to the kAIMetadataSyncNotifier notifier and doing it there.

Known Participant
February 17, 2015

Thanks for answering,

I was trying towrite into the document dictionary at different places, with and  without notifiers (docchange, action complete,, etc..), including your suggestion kAIMetadataSyncNotifier

My subroutine is as follows

void ecrireChaineDansDicoDoc(const char* name, char * value)

{

  AIErr error;

  AIDictionaryRef dictionary = 0;

  AIAppContextHandle context = 0;

  SPPluginRef pluginRef; // this needs to be picked up and stored from one of your load messages

  pluginRef = gPluginRef;

  // plus de mal que de bien worse than better

  // error = sAppContext->PushAppContext(pluginRef, &context);

  error = sAIDocument->GetDictionary(&dictionary);

  // check error

  if (dictionary)

  {

  AIDictKey key = sAIDictionary->Key(name);

  error = sAIDictionary->SetStringEntry(dictionary, key, value);

  // check error

  sAIDictionary->Release(dictionary);

  }

It hangs on the SetStringEntry instruction.

Any clue?

Inspiring
February 17, 2015

Not sure, but I'd also make sure to check the returned error value from


error = sAIDocument->GetDictionary(&dictionary);

Just to make sure to catch unmet assumptions (i.e. I think you're assuming that if the call fails, dictionary will be NULL. That assumption is probably correct, but I would not bet on it, and I'd check the error code first).

Often the error codes have valuable info in them. For myself, I've compiled a list of various error codes by GREP-ping the SDK folder, which I found very useful. I am not sure whether there is a proper list available somewhere - I haven't found it, but I also haven't looked very hard.