{"action":"created","issue":{"url":"https://api.github.com/repos/typesupply/defcon/issues/29","labels_url":"https://api.github.com/repos/typesupply/defcon/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/typesupply/defcon/issues/29/comments","events_url":"https://api.github.com/repos/typesupply/defcon/issues/29/events","html_url":"https://github.com/typesupply/defcon/issues/29","id":114412614,"number":29,"title":"[ufo3] notifications timing problems","user":{"login":"adrientetar","id":1250894,"avatar_url":"https://avatars.githubusercontent.com/u/1250894?v=3","gravatar_id":"","url":"https://api.github.com/users/adrientetar","html_url":"https://github.com/adrientetar","followers_url":"https://api.github.com/users/adrientetar/followers","following_url":"https://api.github.com/users/adrientetar/following{/other_user}","gists_url":"https://api.github.com/users/adrientetar/gists{/gist_id}","starred_url":"https://api.github.com/users/adrientetar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrientetar/subscriptions","organizations_url":"https://api.github.com/users/adrientetar/orgs","repos_url":"https://api.github.com/users/adrientetar/repos","events_url":"https://api.github.com/users/adrientetar/events{/privacy}","received_events_url":"https://api.github.com/users/adrientetar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-31T13:47:00Z","updated_at":"2015-10-31T15:09:56Z","closed_at":null,"body":"So I was implementing a way to move a glyph to another layer. I call `glyph.clearContours()` after inserting the glyph into another layer.\r\n\r\nThe problem that I have is that I have representations of my glyph that are destroyed when `Glyph.Changed` is emitted, and I also update my view when `Glyph.Changed` emitted.\r\n\r\nThe thing is that apparently defcon calls my update callbacks before destroying the representations. It makes the application crash when it trys to access data that was removed:\r\n\r\n```\r\nRLS Layer.GlyphWillBeAdded <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.GlyphAdded <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04AEC430>\r\nRLS Glyph.ContourWillBeDeleted <defconQt.objects.defcon.TGlyph object at 0x04C38CB0>\r\nRLS Glyph.ContoursChanged <defconQt.objects.defcon.TGlyph object at 0x04C38CB0>\r\nRLS Glyph.Changed <defconQt.objects.defcon.TGlyph object at 0x04C38CB0>\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\Admin\\Downloads\\trufont\\Lib\\defconQt\\glyphView.py\", line 428, in _layerMove\r\n    self.view.layerMove()\r\n  File \"C:\\Users\\Admin\\Downloads\\trufont\\Lib\\defconQt\\glyphView.py\", line 2385, in layerMove\r\n    self._glyph.clearContours()\r\n  File \"C:\\Python34\\lib\\site-packages\\defcon\\objects\\glyph.py\", line 523, in clearContours\r\n    self.releaseHeldNotifications()\r\n  File \"C:\\Python34\\lib\\site-packages\\defcon\\objects\\base.py\", line 162, in releaseHeldNotifications\r\n    dispatcher.releaseHeldNotifications(observable=self, notification=notification)\r\n  File \"C:\\Python34\\lib\\site-packages\\defcon\\tools\\notifications.py\", line 251, in releaseHeldNotifications\r\n    self.postNotification(notification, observableRef(), data)\r\n  File \"C:\\Python34\\lib\\site-packages\\defcon\\tools\\notifications.py\", line 195, in postNotification\r\n    callback(notificationObj)\r\n  File \"C:\\Users\\Admin\\Downloads\\trufont\\Lib\\defconQt\\glyphView.py\", line 2010, in _glyphChanged\r\n    self.activeGlyphChanged()\r\n  File \"C:\\Users\\Admin\\Downloads\\trufont\\Lib\\defconQt\\glyphView.py\", line 2032, in activeGlyphChanged\r\n    self.updateActiveLayer()\r\n  File \"C:\\Users\\Admin\\Downloads\\trufont\\Lib\\defconQt\\glyphView.py\", line 2041, in updateActiveLayer\r\n    self.addPoints()\r\n  File \"C:\\Users\\Admin\\Downloads\\trufont\\Lib\\defconQt\\glyphView.py\", line 2318, in addPoints\r\n    self._glyph[onCurve.contourIndex],\r\n  File \"C:\\Python34\\lib\\site-packages\\defcon\\objects\\glyph.py\", line 1023, in __getitem__\r\n    return self._contours[index]\r\nIndexError: list index out of range\r\n```\r\n\r\nIf I return early in my widgets instead of updating I can see the calls to destroy happening:\r\n\r\n```\r\nRLS Layer.GlyphWillBeAdded <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.GlyphAdded <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.GlyphChanged <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Layer.Changed <defcon.objects.layer.Layer object at 0x04C46930>\r\nRLS Glyph.ContourWillBeDeleted <defconQt.objects.defcon.TGlyph object at 0x04E4EB30>\r\nRLS Glyph.ContoursChanged <defconQt.objects.defcon.TGlyph object at 0x04E4EB30>\r\nRLS Glyph.Changed <defconQt.objects.defcon.TGlyph object at 0x04E4EB30>\r\nDESTROY defconQt.QPainterPath\r\nDESTROY defconQt.OutlineInformation\r\nDESTROY defconQt.StartPointsInformation\r\nDESTROY defconQt.NoComponentsQPainterPath\r\n```\r\n\r\nI could set my representations to be destroyed when `ContourWillBeDeleted` is emitted (is it meant to be so? ufo3 defconAppkit does not seem to care about `ContourWillBeDeleted` specially, but it isn't capable of editing either) but I feel like there are other cases where such a thing could happen. \r\n@typesupply What do you think? I would say that destroying needs to be prioritized over other notifications."},"comment":{"url":"https://api.github.com/repos/typesupply/defcon/issues/comments/152741690","html_url":"https://github.com/typesupply/defcon/issues/29#issuecomment-152741690","issue_url":"https://api.github.com/repos/typesupply/defcon/issues/29","id":152741690,"user":{"login":"adrientetar","id":1250894,"avatar_url":"https://avatars.githubusercontent.com/u/1250894?v=3","gravatar_id":"","url":"https://api.github.com/users/adrientetar","html_url":"https://github.com/adrientetar","followers_url":"https://api.github.com/users/adrientetar/followers","following_url":"https://api.github.com/users/adrientetar/following{/other_user}","gists_url":"https://api.github.com/users/adrientetar/gists{/gist_id}","starred_url":"https://api.github.com/users/adrientetar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrientetar/subscriptions","organizations_url":"https://api.github.com/users/adrientetar/orgs","repos_url":"https://api.github.com/users/adrientetar/repos","events_url":"https://api.github.com/users/adrientetar/events{/privacy}","received_events_url":"https://api.github.com/users/adrientetar/received_events","type":"User","site_admin":false},"created_at":"2015-10-31T15:09:56Z","updated_at":"2015-10-31T15:09:56Z","body":"It doesn't seem to be an ordering issue..."}}