I got into the state where I could not open a FileList and tracked
it down to the ToolBuilder default having retained some state from
an earlier error building a new widget. In particular, the
<parent> ivar was still pointing to some previous SystemWindow
and gthat caused error when trying to create the buttons on the
FileList.
In ToolBuilder, one could add an ensure: to see that parent always gets reset: buildAll: aList in: newParent "Build the given set of widgets in the new parent" | prior | aList ifNil:[^self]. prior := parent. [ parent := newParent. aList do:[:each| each buildWith: self]. ] ensure: [ "<<<<" parent := prior. ]. but I guess a better question is why Toolbuilder default doesn't automatically return a clean builder? Cheers, Bob |
On Wed, Sep 11, 2013 at 08:54:13AM -0400, Bob Arning wrote:
> I got into the state where I could not open a FileList and tracked it > down to the ToolBuilder default having retained some state from an > earlier error building a new widget. In particular, the <parent> ivar > was still pointing to some previous SystemWindow and gthat caused error > when trying to create the buttons on the FileList. > > In ToolBuilder, one could add an ensure: to see that parent always gets > reset: > > buildAll: aList in: newParent > "Build the given set of widgets in the new parent" > | prior | > aList ifNil:[^self]. > prior := parent. > [ > parent := newParent. > aList do:[:each| each buildWith: self]. > ] ensure: ["<<<<" > parent := prior. > ]. > > but I guess a better question is why Toolbuilder default doesn't > automatically return a clean builder? > > Cheers, > Bob Good question. It was probably a matter of design style. Every Project has a UIManager, and that UIManager has its own ToolBuilder instance. That has a nice feel to it, and it makes the roles of these things seem more clear. It also avoids the need to figure out what kind of ToolBuilder to create each time time you use one (normally a trivial concern but possibly more complicated when entering one kind of project from another). On the other hand, keeping transient state in the instance variables in not a very good thing for the reasons you found, so I'm not sure the best way to handle that. Another approach might be to reset the tool builder prior to using it to build something. Two processes would not be allowed to share one tool builder, but that is implicit in the design already, so it is similar to dealing with a stream in that respect. Dave |
It's fine that each UIManager has its own kind
of ToolBuilder, but why reuse a single instance over and over?
You have now: UIManager>>toolBuilder ^toolBuilder MorphicUIManager>>initialize toolBuilder := MorphicToolBuilder new MVCUIManager>>initialize toolBuilder := MVCToolBuilder new so, why that rather than: MorphicUIManager>>toolBuilder ^ MorphicToolBuilder new MVCUIManager>>toolBuilder ^MVCToolBuilder new ? Cheers, Bob On 9/11/13 9:33 AM, David T. Lewis
wrote:
Good question. It was probably a matter of design style. Every Project has a UIManager, and that UIManager has its own ToolBuilder instance. That has a nice feel to it, and it makes the roles of these things seem more clear. It also avoids the need to figure out what kind of ToolBuilder to create each time time you use one (normally a trivial concern but possibly more complicated when entering one kind of project from another). |
The only practical reason that comes to mind is the case of entering
e.g. an MVCProject from a MorphicProject. There is a transition period during which some things are being done in the project being entered, and some things are being done to the project that you are leaving. I can't say if this would lead to problems in practice (it would be easy to try it but I can't do so at the moment). Dave On Wed, Sep 11, 2013 at 10:05:01AM -0400, Bob Arning wrote: > It's fine that each UIManager has its own kind of ToolBuilder, but why > reuse a single instance over and over? > > You have now: > > UIManager>>toolBuilder > ^toolBuilder > > MorphicUIManager>>initialize > toolBuilder := MorphicToolBuilder new > > MVCUIManager>>initialize > toolBuilder := MVCToolBuilder new > > so, why that rather than: > > MorphicUIManager>>toolBuilder > ^ MorphicToolBuilder new > > MVCUIManager>>toolBuilder > ^MVCToolBuilder new > > ? > > Cheers, > Bob > > On 9/11/13 9:33 AM, David T. Lewis wrote: > >Good question. It was probably a matter of design style. Every Project has > >a UIManager, and that UIManager has its own ToolBuilder instance. That has > >a nice feel to it, and it makes the roles of these things seem more clear. > >It also avoids the need to figure out what kind of ToolBuilder to create > >each time time you use one (normally a trivial concern but possibly more > >complicated when entering one kind of project from another). > > |
Free forum by Nabble | Edit this page |