mekkablue
(Rainer Erich Scheichelbauer)
March 16, 2018, 2:44pm
1
There is a bug in the Glyphs.registerDefault()
method. It always registers the string GlyphsToolHand
, no matter what you specify. Paste and run this in the Macro Window:
Glyphs.registerDefault("com.mekkablue.testCase",1)
print Glyphs.defaults["com.mekkablue.testCase"]
Result: GlyphsToolHand
:-/
not for me. And registering only sets a default value if nothing was actually set. What happens if you do
Glyphs.registerDefault("com.mekkablue.testCase",1)
del(Glyphs.defaults["com.mekkablue.testCase"])
print Glyphs.defaults["com.mekkablue.testCase"]
do you have an old GlyphsApp.py in your script folder? Can you rename Script and Plugins folder and restart Glyphs?
Mark
(Mark Frömberg aka Mark2Mark)
March 16, 2018, 5:26pm
3
Ohhh, I think I saw something like that recently when we struggled to get the Distance and Angle plugin working on @Frode_Helland ’s machine. I don’t know exactly what happened, but I remember some wrong default entry happening. I’ll check later …
Edit
When I run @mekkablue ’s lines from above, the same happens. It prints GlyphsToolHand
in build 1122
There has to be something that causes this. Can you try to start without plugins (hold opt+shift when starting the app)?
mekkablue
(Rainer Erich Scheichelbauer)
March 17, 2018, 6:52am
5
Same thing I am afraid. Also seen it on other people’s installations. Something wrong in the wrapper maybe?
What happens with
print NSUserDefaults.standardUserDefaults().objectForKey_("com.mekkablue.testCase")
You don’t need to register
the defaults every time.
And if you do:
NSUserDefaults.standardUserDefaults().setObject_forKey_(1, "com.mekkablue.testCase")
print NSUserDefaults.standardUserDefaults().objectForKey_("com.mekkablue.testCase")
one more test:
NSUserDefaults.standardUserDefaults().setObject_forKey_(1, NSString.stringWithString_(u"com.mekkablue.testCase"))
print NSUserDefaults.standardUserDefaults().objectForKey_(NSString.stringWithString_(u"com.mekkablue.testCase"))
If that is giving you strange results, then there is something wrong with your system.
mekkablue
(Rainer Erich Scheichelbauer)
March 19, 2018, 1:19pm
7
This works as expected. Just when I Glyphs.registerDefault()
first, it will prepopulate the key’s value with GlyphsToolHand
.
It does not matter how I print the value, be it via NSUserDefaults.standardUserDefaults().objectForKey_()
or Glyphs.defaults[]
.
Also, I see this in init.py:
def __registerDefaults__(self, defaults):
if defaults != None:
NSUserDefaults.standardUserDefaults().registerDefaults_(defaults)
else:
raise ValueError
GSApplication.registerDefaults = __registerDefaults__
But Glyphs.registerDefaults({"com.mekkablue.test":1})
yields an AttributeError: ‘GSApplication’ object has no attribute ‘registerDefaults’ .
@GeorgSeifert : Check the implementation of __registerDefaults__()
. I think there might be a typo referencing value
versus values
at different spots in the method. That might be the cause of this GlyphsHandTool
default issue.
2 Likes
You are right. Thanks for finding this.