Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interference with other Plugin(s) #33

Closed
Mark2Mark opened this issue Feb 25, 2022 · 12 comments
Closed

Interference with other Plugin(s) #33

Mark2Mark opened this issue Feb 25, 2022 · 12 comments

Comments

@Mark2Mark
Copy link

Mark2Mark commented Feb 25, 2022

Sometimes I had users reporting, that my Variable Font Preview goes a little loco when the Red Arrows Plugin is also active.

I could now reproduce this while improving management of multiple fonts. Once Red Arrows is active, VFP can only deal with the first open font well. Wenn switching to another font, the redrawing gets very glitchy.

@jenskutilek do you happen to have an idea what part of Red Arrows could potentially cause other plugins to be affected in a way or another?

VFP is written in objc and I am prefixing all my classes. Currently I am rather clueless.

Edit: It is even more curious: When I launch Glyphs with Red Arrows off, VFP also behaves odd in some spots, then I turn RA on, and it keeps odd, but when turning RA off then, all is fine. :D

Not blaming your code at all. Just wanted add it for the record …

@schriftgestalt
Copy link
Collaborator

It might be related to assigning the current window controller for each drawing operation. And with the mouse moved callbacks from Red Arrows that might get called in the wrong order or is overwriting things.

@Mark2Mark
Copy link
Author

Thanks! Is there anything I can improve on my side? I am currently fixing the currentFontDocument handling. Maybe a way of checking for the correct window controller in my drawing operations?

@schriftgestalt
Copy link
Collaborator

I would need to check the code that access the the fonts.
and what is actually not working?

@Mark2Mark
Copy link
Author

It’s quite hard to describe. I’ll clean up the messy code a bit and then will show you. Basically when it works weidly, the live update on slider changes of the drawing happens only in the first opened font document, but only updates after a slider changed and the mouse is let go in all other font documents.

Then, when I enable Red Arrows, the same happens. But when I then disable RA, and wiggle around the sliders, the live update works well in all open documents.

@jenskutilek
Copy link
Owner

If I remember correctly, Georg optimized a part of my code so that the outline check doesn't need to be updated that often.

I vaguely remember that I had similar experiences as you, @Mark2Mark, in that the updating and the live showing/hiding of error labels works more reliably when it is once deactivated (context menu: Show Error Labels), then activated again. I never really found out what causes this.

Sorry that I can't be of more help ...

@Mark2Mark
Copy link
Author

Don’t worry. That helps already a bit in that it seems that I am not alone with this experience. Will further investigate. Thanks so much for both of your helps.

@Mark2Mark
Copy link
Author

Mark2Mark commented Mar 1, 2022

Adding some investigation. As it seemed to "fix" VFP when RA is enabled and disabled again, we thought to start looking into the willDeactivate method. There RA calls self.stopMouseMoved() which again only calls NSNotificationCenter.defaultCenter().removeObserver_(self)

Interesting is, that self.stopMouseMoved() is also called from toggleLabels_. So I tried with the oddly behaving VFP, activating RA, but now instead of deactivating it, toggling the Error Label setting, which as expected also "fixes" VFP.

The RA observer of interest here is NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.mouseDidMove_, MOUSEMOVED, objc.nil). Not sure if that helps anyone of us, but it could be a hint (not at least because you also mentioned the Error Labels)


Note: "odd" behaving VFP means, that the drawings in the EditView don’t live update in any but the first opened font, when there are several fonts open. In all other fonts, the drawing only updates when the user releases a slider after moving it. "fixed" means, all fonts show live updating drawings in their EditViews.

@Mark2Mark
Copy link
Author

Last discovery from Georg’s tip:

def mouseDidMove_(self, notification):
	pass # Glyphs.redraw()

makes VFP work entirely as expected. Georg has enough information now to look into it. But it’s not a high priority, so we can leave this just as a reminder here for later.

@schriftgestalt
Copy link
Collaborator

schriftgestalt commented Mar 1, 2022

can you try this in the mouseDidMove_:

	def mouseDidMove_(self, notification):
		try:
			notification.object().window().windowController().activeEditViewController().graphicView().setNeedsDisplay_(True)
		except Exception as e:
			import traceback
			print(traceback.format_exc())

It will only redraw the edit view that the mouse is over. So it might avoid the tow fonts problem. (that we should fix, too).

@Mark2Mark
Copy link
Author

🍀 This w❤️rks like a charm 🍀

@jenskutilek
Copy link
Owner

jenskutilek commented Mar 3, 2022

I've added @schriftgestalt’s suggestion to my code (93bd4ff). Thank you!

@Mark2Mark
Copy link
Author

Thank you too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants