Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I just want to pop this up to the top again. I am running into a similar issue.
I am registering my plugin group in my StartupPlugin(...) method, and I did not using a local variable for AIAddPluginData.
My code to generate the PluginGroup seems to work fine. The art is created as I expect and shows up in the document. My problem seems to be around Undo/Redo.
Sometimes when I debug my code, there are several extra "Undo" steps created. I undo, undo, undo until I get to the step that actually "undo's" my art creation. Sometimes just the one undo is created like I'd expect.
Then, if I choose "Redo", Illustrator hangs. There's no crash, and when I pause in the debugger it seems to be in Illustrator code outside my plugin. If I let it go, I can see the used memory climb as Illustrator continues to try and do.... something?
If I comment out the one line where I SetPluginArtResultArt(...), the code works fine. If I leave that line in, it returns no error code.
I know it's hard to diagnose without me posting my whole code. Maybe there's some aspect of setting up a plugin art that I've overlooked?
For the time being I haven't bothered to handle the PluginGroupUpdate(...) stuff because it didn't seem necessary for my application, but maybe it is?
Copy link to clipboard
Copied
Need a little more information to help. How are you actually populating the PluginArt? You said you create, but then how does it get filled with, well, stuff?
Undo is a mess with PluginArt, but I don't recall seeing multiple undo-steps. I'm guessing there's an obvious source once we drill down to it.
Copy link to clipboard
Copied
In response to my menu event:
AIArtHandle pluginGroupArt;
AIErr err = sAIArt->NewArt(kPluginArt, kPlaceInsideOnBottom, prep, &pluginGroupArt);
sAIPluginGroup->UseAIPluginGroup( pluginGroupArt, gPlugin->GetPluginGroupHandle() );
AIArtHandle resultGroupArt;
sAIArt->NewArt(kGroupArt, kPlaceInsideOnBottom, prep, &resultGroupArt);
AIArtHandle tickMarkArt;
sAIArt->NewArt(kPathArt, kPlaceInsideOnTop, resultGroupArt, &tickMarkArt);
AIPathSegment segments[3];
segments[0] = { .corner = true, .p = {.h = 0, .v = 0}, .in = {.h = 0, .v = 0}, .out = {.h = 0, .v = 0} };
segments[1] = { .corner = true, .p = {.h = 1, .v = 1}, .in = {.h = 1, .v = 1}, .out = {.h = 1, .v = 1} };
segments[2] = { .corner = true, .p = {.h = 2, .v = 2}, .in = {.h = 2, .v = 2}, .out = {.h = 2, .v = 2} };
sAIPath->SetPathSegments(tickMarkArt, 0, 3, segments);
sAIPath->SetPathClosed(tickMarkArt, false);
err = sAIPluginGroup->SetPluginArtResultArt(pluginGroupArt, resultGroupArt);
That is enough to recreate the issue. The art is drawn, then undo works, then redo hangs. Let me know if there's anything else I can show.
Copy link to clipboard
Copied
Looking at our code, I think you're better off doing like us.
When you create the kPluginArt, you should get an notifier (caller=kCallerAIPluginGroup, selector=kSelectorAINotifyEdits). The AIPluginGroupMessage data block has a 'code' member that should be kAttachOperationCode (the first time). We respond to that and do all our creation in there.
Further more, we don't ever call SetPluginArtResultArt. You should be able to immediately call GetPluginArtResultArt(); the result & edit groups should already exist. Then you just populate them however you wish.
Try that and see if your undo/redo issues go away. It doesn't sound like you're doing anything remotely strange art-wise, so I suspect it's just the the trappings of kPluginArt that's screwing you up.
Copy link to clipboard
Copied
I changed:
AIArtHandle resultGroupArt;
sAIArt->NewArt(kGroupArt, kPlaceInsideOnBottom, prep, &resultGroupArt);
to:
AIArtHandle resultGroupArt;
sAIPluginGroup->GetPluginArtResultArt(pluginGroupArt, &resultGroupArt);
and now Undo/Redo works. I will have to port those results to my actual production code to see whether your other suggestions wind up being necessary. Thank you very much!
Copy link to clipboard
Copied
It looks like if I use
sAIArt->NewArt(kPathArt, kPlaceInsideOnTop, resultGroupArt, &tickMarkArt);
but if I
sAIArt->ReorderArt(tickMarkArt, kPlaceInsideOnTop, resultGroupArt);
then I get a 'PARM' error and the art is created, but left outside of the plugin group.
Copy link to clipboard
Copied
Looking at our code, I don't see any places where we create art outside and move it inside (we always create it right in the sub-tree of the result or edit groups), so that may be a requirement. Odd though, I don't see why that shouldn't be allowed.
Copy link to clipboard
Copied
Neither do I! But I've got it working now, thanks. I couldn't have figured this out without your help.
Copy link to clipboard
Copied
Back to this old chestnut.
I updated everything to Illustrator CC 2017, and now I'm getting a crash when I save a file that I have created my plugin art in. The crash happens outside my code, but I have tracked the problem down to a spot in my code:
sAIArt->NewArt(kPluginArt, kPlaceInsideOnBottom, prep, &pluginGroupArt);
AIErr err = sAIPluginGroup->UseAIPluginGroup(pluginGroupArt, myPluginGroupHandle);
err is 'VALD' here. The docs say "Return code for response to kSelectorAINotifyEdits at kAfterOperationTime, if the plug-in group has already updated the object." I'm not really sure why this code would return that error code. Maybe it's a bug?
My next thought was to try the function AIPluginGroupSuite->SetPluginArtPluginGroup(...), but that function seems to be unfinished. The docs say it takes two parameters, but the actual function only takes one and it's only the art handle to change, not the target plugin group. Another bug?
Copy link to clipboard
Copied
It looks like this is related to my answer on this thread: https://forums.adobe.com/thread/2215301
In my handler for PluginGroupNotify(...), I was returning kMarkValidPluginGroupReply in response to kAttachOperationCode, kAfterOperationTime.
This is what was causing UseAIPluginGroup(...) to return kMarkValidPluginGroupReply. Apparently that causes other problems that I hadn't come across in previous versions.
I removed any handling in PluginGroupNotify and just return kUnhandledMsgErr there.
This seems to have cleared up my crashes on saving my file.
I can't even really remember what issue handling PluginGroupNotify was supposed to solve, I don't appear to be having the recursive draw issue I was having now without it.