Strange behaviour with Font.enableUpdateInterface() after recent upgrade


#1

Hi

I recently upgraded to Mojave and Version 2.5.2 (1181) and some scripts which use Font.enableUpdateInterface() have been running strangely.

I am connecting buttons on the midi controller to be able to select prev/next nodes. Everything seems to run without errors and you can even see the node coordinates changing but the issue is that the new selected node is only seen after I actually move inside the glyph window.

(missing codes based on mekkablue’s selecting prev/next node scripts)

issue

    class MyThread(threading.Thread):
    	def run(self):
    		for msg in inport:
			
			    Font = Glyphs.font
    			selectedLayers = Font.selectedLayers
			
			    def getTheFirstPoint(selection):
    				[...]
    			
    			def nextOnCurve(currPoint):
    				[...]

    			def prevOnCurve(currPoint):
    				[...]

    			def next():
    				currentLayer = Glyphs.font.selectedLayers[0] # active layers of selected glyphs
    				selection = currentLayer.selection # node selection in edit mode
    				currentPoint = getTheFirstPoint(selection)
    				if currentPoint:
    					nextOnCurveNode = nextOnCurve(currentPoint)
    					currentLayer.selection = (nextOnCurveNode,)
    						
    			def prev():
    				currentLayer = Glyphs.font.selectedLayers[0] # active layers of selected glyphs
    				selection = currentLayer.selection # node selection in edit mode
    				currentPoint = getTheFirstPoint(selection)
    				if currentPoint:
    					prevOnCurveNode = prevOnCurve(currentPoint)
    					currentLayer.selection = (prevOnCurveNode,)
    			
    		
    			if msg.control == 61:
    				def process():
    					next()
    				
    			if msg.control == 62:
    				def process():
    					prev()

    			Font.disableUpdateInterface()
    			process()
    			Font.enableUpdateInterface()
    		
    m = MyThread()
    m.start()

#2

Quick stab at it from on the go:

  1. You do not need Font.disableUpdateInterface() here, it is only for many changes at once, where many redraws would slow down too much. For a single change, it does not make sense.
  2. Redraw should be triggered automatically when something changes, I have a suspicion that it has to do with the threading applied here, but I have too little experience with threading.

#3

I removed Font.disableUpdateInterface() and it still had the same behaviour. I ended up reverting back to Version 2.5.1 (1141) and it works.


#4

What happens if you remove the Font.disableUpdateInterface() in 1141?


#5

I removed Font.disableUpdateInterface() Font.enableUpdateInterface() and process() so the last part is this:

        if msg.control == 61:
			print 'NEXT'
			next()
			
		if msg.control == 62:
			print 'PREV'
			prev()
	
m = MyThread()
m.start()

Same code works in 1141 but not 1181.


#6

Ok we‘re investigating.


#7

I tried to replicate this and it works fine for me.