Copy link to clipboard
Copied
I get some weird exceptions. I tried to track it by some experiments with sample projects and at some point I managed to make it go away just by adding some unused array in some place in the code. My code is a little different and I'm unable to achieve it there. I tried to use other functions but the exception pops up somewhere else. The behavior with unused variable look like a problem with memory overwriting.
To demonstrate the problem replace SnippetRunnerPlugin::Message body with:
ASErr result = kNoErr;
//char abc[1024]; ZeroMemory(abc, 1024);
result = Plugin::Message(caller, selector, message);
return result;
and in SnippetRunnerPlugin::GoMenuItem replace fAboutPluginMenu handler with:
ASErr result = kNoErr;
try {
AINewDocumentPreset settings;
SDK_ASSERT(sAIDocumentList);
ai::UnicodeString preset("Print");
result = sAIDocumentList->GetPresetSettings(preset, &settings);
aisdk::check_ai_error(result);
ai::UnicodeString prst;
AIDocumentHandle document;
result = sAIDocumentList->New(prst, &settings, kDialogNone, &document);
aisdk::check_ai_error(result);
SDK_ASSERT(document);
}
catch (ai::Error& ex) {
result = ex;
}
Now compile plugin in debug, copy it to plugins folder, run Illustrator, go to help->About SDK plugins->Snippet Runner... . Illustrator crashes on sAIDocumentList->New. Now in SnippetRunnerPlugin::Message uncomment the array line. Repeat above steps - new page is being created. Also release version runs successfully, but it's not the case in my code. Is there anything I'm doing wrong?
I used Adobe Illustrator SDK Build 20161110.sdk.95609, VisualStudio 2015, Windows 10, Illustrator CC 22.1 (64-bit).
Copy link to clipboard
Copied
It looks like the GetPresetSettings function is broken. In CC 2015.3 and earlier versions it works correctly. In CC 2017 (22.x) and CC 2018 (23.x) it is broken. It still returns an error if the preset doesn't exist, but if the preset does exist, it returns 0, but doesn't fill in the AINewDocumentPreset structure. Your code is therefore using uninitialized data and anything can happen.
Copy link to clipboard
Copied
I have submitted a bug for this to Adobe. Vote for "GetPresetSettings function doesn't work correctly in CC 2017 and later":
Illustrator Bugs: SDK and Scripting (17 ideas) – Adobe Illustrator Feedback