[Cuis-dev] BoxedMorph post-class definition change recompilation failure
Gerald Klix
cuis.01 at klix.ch
Fri Mar 24 01:23:11 PDT 2023
On 3/24/23 8:31 AM, Alexandre Rousseau via Cuis-dev wrote:
> I'm trying to modify rather than subclass BoxedMorp, adding a new instance
> var to the class definition. This fails while Transcript reports what
> follows.
>
> I'm guessing that recompilation of BoxedMorph does not play well while a
> WorldMorph (a subclass of BoxedMorph itself) instance is running.
>
> What would be a way to work around this?
>
> Class reshaping: InnerTextMorph has some instance running #acceptContents.
>> This CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: InnerTextMorph has some instance running
>> #processKeystrokeEvent:. This CompiledMethod would become invalid. Class
>> reshaping aborted.
>> Class reshaping: InnerTextMorph has some instance running
>> #processKeystrokeEvent:. This CompiledMethod would become invalid. Class
>> reshaping aborted.
>> Class reshaping: InnerTextMorph has some instance running #keyStroke:.
>> This CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: InnerTextMorph has some instance running #keyStroke:.
>> This CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: HandMorph has some instance running
>> #startKeyboardDispatch:. This CompiledMethod would become invalid. Class
>> reshaping aborted.
>> Class reshaping: HandMorph has some instance running #processEventQueue.
>> This CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: WorldMorph has some instance running #doOneCycleNow. This
>> CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: WorldMorph has some instance running #handsDo:. This
>> CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: WorldMorph has some instance running #doOneCycleNow. This
>> CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: WorldMorph has some instance running #doOneCycle:. This
>> CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: WorldMorph has some instance running #mainLoop. This
>> CompiledMethod would become invalid. Class reshaping aborted.
>> Class reshaping: WorldMorph has some instance running #mainLoop. This
>> CompiledMethod would become invalid. Class reshaping aborted.
>
First, let me analyze that problem.
Nearly every Morph you see on the screen – SystemWindow and
thus BrowserWindow – is derived from BoxedMorph. Juan added save guards
to Object>>#become:, because adding the target object of #become:
might still have some active contexts on the stack and these
active contexts refer to methods that where compiled for the
source object of #bceome:. In your case the source object
is the old class and the target object is the new class, with
the added instance variable. If you will add the instance variable
add the end, it would work out. Otherwise some
morphic code in the running system will certainly crash.
Now for ways around this mess:
Do you really need an instance variable?
Morphs also have properties, that should
be used if the instance variable is nil for
most morphs. Properties come in handy here,
because the can be added at run-time.
If you insist on adding instance variables,
you have to add your variable with
no morphic code on the stack, meaning you have to
do it from the command line.
There is a method Class>>#addInstVarName: that lets
you add instance variables.
You can use the -e command-line option
to execute code from the command line.
HTH,
Gerald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230324/613bb695/attachment.htm>
More information about the Cuis-dev
mailing list