[Pharo-project] System announcements and MC
I subscribed to the ClassModifiedClassDefinition announcement to be notified when an inst var is added to a class, but I get notifications when MC is loading things. This seems like a very different type of event than when one manually adds an inst var via the browser, but I don't see a way to tell which is happening based on the contextual info the announcement gives me. Sean -- View this message in context: http://forum.world.st/System-announcements-and-MC-tp4577351p4577351.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Sean P. DeNigris wrote
I get notifications when MC is loading things
Strange... I only get the announcements when class-side instance variables are added via MC... It seems that the reason is that MCClassDefinition>>load creates the class in two steps: 1. MCClassDefinition>>createClass takes care of all the instance side stuff, and correctly notifies of a new class 2. Metaclass>>instanceVariableNames: adds the class-side instance variable names to the class, which now already exists; so the notification is of a changed class definition -- View this message in context: http://forum.world.st/System-announcements-and-MC-tp4577351p4577658.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Issue created: http://code.google.com/p/pharo/issues/detail?id=5652 1.4 #14438 When loading a class, I would expect a single ClassAdded announcement. Instead, we get a ClassAdded announcement, and then a ClassModifiedClassDefinition for the class (I think when the category is set), and then a ClassModifiedClassDefinition for the metaclass, but only if there are class-side instance variables. 1. Subscribe for class definition change announcements e.g. "SystemAnnouncer current on: ClassModifiedClassDefinition send: #classModified: to: self new." 2. Subscribe for class added announcements e.g. "SystemAnnouncer current on: ClassModifiedClassDefinition send: #classAdded: to: self new." 3. Load a package with MC that contains a class with a class-side instance variable and an instance-side instance variable You will see that your handler from #1 gets called twice and #2 once. -- View this message in context: http://forum.world.st/System-announcements-and-MC-tp4577351p4577660.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On Sun, Apr 22, 2012 at 6:39 AM, Sean P. DeNigris <sean@clipperadams.com>wrote:
Sean P. DeNigris wrote
I get notifications when MC is loading things
Strange... I only get the announcements when class-side instance variables are added via MC...
It seems that the reason is that MCClassDefinition>>load creates the class in two steps: 1. MCClassDefinition>>createClass takes care of all the instance side stuff, and correctly notifies of a new class 2. Metaclass>>instanceVariableNames: adds the class-side instance variable names to the class, which now already exists; so the notification is of a changed class definition
hahahaa I think that's a good catch ;) Probably the easiest yet not-so-beatiful solution is to do something like this: load self createClass ifNotNil: [:class | SystemChangeNotifier uniqueInstance doSilently: [ class class instanceVariableNames: self classInstanceVariablesString. self hasComment ifTrue: [class classComment: comment stamp: commentStamp]] ] :(
-- View this message in context: http://forum.world.st/System-announcements-and-MC-tp4577351p4577658.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- Mariano http://marianopeck.wordpress.com
Mariano Martinez Peck wrote
Probably the easiest yet not-so-beatiful solution is to do something like this:
Yes, I was thinking the same... Not too bad a temporary solution since the notification stuff needs to be cleaned anyway... -- View this message in context: http://forum.world.st/System-announcements-and-MC-tp4577351p4578308.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
MC was also loading all classes twice (which explains the instance-side class def changed notifications), so I fixed that too... Fix in inbox: SLICE-Issue-5652-MC-incorrect-announcements-on-class-load-SeanDeNigris.1 * Fixed inappropriate class definition changed notifications during MC loading * Fixed related bug where MC was loading classes twice (see MCPackageLoader>>basicLoad) Sean -- View this message in context: http://forum.world.st/System-announcements-and-MC-tp4577351p4578356.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
I di not check (just wake up) but the announcement of system announcement are normally just wrapping the systemChangeNotifier. We will start to work on removing SystemChangeNotifier. So there are probably cases that were not well covered by systemNotifier or some bugs inside. Stef On Apr 22, 2012, at 1:34 AM, Sean P. DeNigris wrote:
I subscribed to the ClassModifiedClassDefinition announcement to be notified when an inst var is added to a class, but I get notifications when MC is loading things. This seems like a very different type of event than when one manually adds an inst var via the browser, but I don't see a way to tell which is happening based on the contextual info the announcement gives me.
Sean
-- View this message in context: http://forum.world.st/System-announcements-and-MC-tp4577351p4577351.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
participants (3)
-
Mariano Martinez Peck -
Sean P. DeNigris -
Stéphane Ducasse