diff --git a/GlyphConstruction.roboFontExt/info.plist b/GlyphConstruction.roboFontExt/info.plist
index 18d92e7..5a8a92f 100644
--- a/GlyphConstruction.roboFontExt/info.plist
+++ b/GlyphConstruction.roboFontExt/info.plist
@@ -30,8 +30,8 @@
requiresVersionMinor
5
timeStamp
- 1594285837.2753458
+ 1594289843.4766321
version
- 0.8.4
+ 0.8.5
diff --git a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py
index 5a64f72..68da9e7 100644
--- a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py
+++ b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py
@@ -1,3 +1,4 @@
+import asyncio
from fontTools.misc.py23 import *
from AppKit import *
import re
@@ -32,6 +33,15 @@
from lib.scripting.codeEditor import CodeEditor
import os
+
+def asyncTask(func):
+
+ def wrapper(*args, **kwargs):
+ task = asyncio.create_task(func(*args, **kwargs))
+
+ return wrapper
+
+
defaultKey = "com.typemytype.glyphBuilder"
constructions = """# capitals
@@ -622,8 +632,12 @@ def unsubscribeFont(self):
self.preview.set([])
self.font.removeObserver(self, notification="Font.Changed")
self.font = None
-
- def constructionsCallback(self, sender, update=True):
+
+ @asyncTask
+ async def constructionsCallback(self, sender, update=True):
+ await asyncio.gather(self._constructionsCallback(sender, update))
+
+ async def _constructionsCallback(self, sender, update=True):
if self.font is None:
return
diff --git a/LibExtension/glyphConstructionController.py b/LibExtension/glyphConstructionController.py
index 5c3327d..e107e4f 100644
--- a/LibExtension/glyphConstructionController.py
+++ b/LibExtension/glyphConstructionController.py
@@ -1,3 +1,6 @@
+import asyncio
+import functools
+
from fontTools.misc.py23 import *
from AppKit import *
import re
@@ -32,6 +35,23 @@
from lib.scripting.codeEditor import CodeEditor
import os
+
+def asyncTask(func):
+
+ taskAttributeName = f"_{func.__name__}_autoCancelTask"
+ @functools.wraps(func)
+ def createFuncTask(self, *args, **kwargs):
+ oldTask = getattr(self, taskAttributeName, None)
+ if oldTask is not None:
+ oldTask.cancel()
+ coro = func(self, *args, **kwargs)
+ task = asyncio.create_task(coro)
+ setattr(self, taskAttributeName, task)
+ return task
+
+ return createFuncTask
+
+
defaultKey = "com.typemytype.glyphBuilder"
constructions = """# capitals
@@ -622,8 +642,12 @@ def unsubscribeFont(self):
self.preview.set([])
self.font.removeObserver(self, notification="Font.Changed")
self.font = None
-
- def constructionsCallback(self, sender, update=True):
+
+ @asyncTask
+ async def constructionsCallback(self, sender, update=True):
+ await asyncio.gather(self._constructionsCallback(sender, update))
+
+ async def _constructionsCallback(self, sender, update=True):
if self.font is None:
return
diff --git a/build-extension.py b/build-extension.py
index 2260a00..f1fd2ff 100644
--- a/build-extension.py
+++ b/build-extension.py
@@ -27,7 +27,7 @@
B.name = "Glyph Construction"
B.developer = 'Frederk Berlaen'
B.developerURL = 'http://typemytype.com/'
-B.version = '0.8.4'
+B.version = '0.8.5'
B.launchAtStartUp = True
B.mainScript = 'glyphConstructionUIStartUp.py'
B.html = True