Skip to main content
Rick E Johnson
Inspiring
January 24, 2024
Question

Can it cause problems to call Push/PopAppContext too often?

  • January 24, 2024
  • 1 reply
  • 201 views

I have a lot of subroutines that create and manipulate art that work reliably when called by a button or menu item, but when this chain of subroutines is called by a system event (updating a PluginGroup's result art), things get complicated. It's my understanding that we then need to call PushAppContext and PopAppContext.

 

Is it sufficient to call them only in the event callback, or does Push/PopAppContext need to be called in every subroutine in the chain?

 

If those subroutines are called when invoked by the user, is it a problem if Push/PopAppContext is called when not necessary?

 

The most common problem I'm having is that when art objects are reordered during a plugin group update, they are sometimes corrupted and have an art type of Unknown. Push/PopAppContext hasn't helped, so I wonder if I'm using it too much or not everywhere it's necessary. Any suggestions would be very much appreciated.

This topic has been closed for replies.

1 reply

Rick E Johnson
Inspiring
February 2, 2024

Please correct me if I'm wrong, but since nobody has responded I'll present my best guess on this.

 

It seems to me that one push/pop context per event should be enough, bookending the callback for the message or notifier.

 

I've been working with arrays (or more recently vectors) of AIArtHandles since I started writing AI plugins in the late 1980s (really). It hasn't been a problem until a plugin that recently does a lot of complex drawing when its art is moved or redrawn. I switched to using AISafeArtHandles in most cases, and it's made a big difference. Most of the glitches happen when reordering art, and about 80% of those mishaps are now eliminated due to AISafeArtHandles rather than AIArtHandles.

 

With luck, I'll make another discovery soon to report here.