Issues porting app from D4 to D5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Issues porting app from D4 to D5

G Krupa
All,

I'm trying to run an app I wrote under D4 on D5.  I'm getting a
walkback when I try and populate the model from a file (see end of
message for walkback).

I subclassed TreeView and added some new functionality I needed
(Lists_TreeView).  I added one instance variable, a boolean (and a
corresponding BooleanAspect for the View Composer to use).  I've
loaded and re-saved the view in D5 and everything looks fine.  The
value of my new aspect does not affect the value of tvFlags, it's
always true (the inst variable being sent #noMask: in
TreeView>>isVirtual).

I'm at a loss.  Has anyone had a similar experience or know what's
going on?  I can't figure out where tvFlags is being set to true,
since it should be an integer, and none of my methods reference it.  I
assume it's the View/resource loader (STBInFile, et al: a part of the
system I don't understand too well).

Cheers,

--GK

--- walkback ---

Unhandled exception - a MessageNotUnderstood('True does not understand
#noMask:')

True(Object)>>doesNotUnderstand:
Lists_TreeView(TreeView)>>isVirtual
Lists_TreeView(TreeView)>>basicAddAll:inHandle:afterHandle:
Lists_TreeView(TreeView)>>refreshContents
Lists_TreeView(View)>>onModelChanged
Lists_TreeView(View)>>model:
TreePresenter(Presenter)>>connectView
TreePresenter(Presenter)>>model:
Lists_ApplicationShell>>model:
Lists_ApplicationShell>>setDocumentData:
Lists_ApplicationShell(DocumentShell)>>streamIn:
Lists_ApplicationShell(DocumentShell)>>fileLoad
Lists_ApplicationShell(DocumentShell)>>fileOpen
Symbol>>forwardTo:
CommandDescription>>performAgainst:
[] in Command>>value
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
Command>>value
ShellView>>performCommand:


Reply | Threaded
Open this post in threaded view
|

Re: Issues porting app from D4 to D5

Ian Bartholomew-18
GK,

> I'm at a loss.  Has anyone had a similar experience or know what's
> going on?  I can't figure out where tvFlags is being set to true,
> since it should be an integer, and none of my methods reference it.  I
> assume it's the View/resource loader (STBInFile, et al: a part of the
> system I don't understand too well).

It looks like what has happened is that between D4 and D5 ObjectArts
added two new instance variables to the TreeView class.  Whenever anyone
adds instance variables to a class then they also have to provide a
method that converts objects stored using the old class shape (the
number of instance variables) into the new shape.

In this case the method involved is TreeView
class>>stbConvertFromVersion10:

This method takes an the array that was loaded from the file (in the old
class format) as an argument.  It then creates a new array suitable for
the new shape of the class and maps objects from the old array into the
new one.  It then initialises the new slots and answers the new array.
So it would do _something_ like

old format array                    new format array
slot 1           ->          slot 1
slot 2           ->          slot 2
.....
slot X         ->         slot X
         0       ->         slot X + 1 (first new iv)
         (nil)    ->        slot X + 2 (second new iv)

The STB In Filer will then load the contents of the "new format array"
into the inst vars of the newly created instance of the class.

The problem is that this conversion doesn't know about your subclass and
it's new inst var (which the STB filer added to the end of the filed out
object).  What therefore actually happens is

old format array                    new format array
slot 1           ->          slot 1
slot 2           ->          slot 2
.....
slot X         ->         slot X
your iv slot   ->          slot X + 1 (first new iv)
       0               ->      slot X + 2 (second new iv)
      (nil)           ->         your iv slot

So what was saved in the position your inst var occupied in the old
class shape is reloaded into the first new inst var that OA added
(tvFlags)

What can you do?.  I would imagine the best way will be to add an
overriding YourTreeView class>>stbConvertFromVersion10: method that
replicates the superclass method but knows about your inst var and
adjusts accordingly.  Maybe something like

stbConvertFromVersion10: array
 "Private - Perform an STB conversion from a version 10 <TreeView> to
version 11,
 i.e. append tvFlags and reserve another slot for later use."

 | newArray size val |
 size := array size.
 newArray := Array new: size + 2. "2 instance variables were added"
 newArray
  replaceFrom: 1
   to: size
   with: array
   startingAt: 1.
 val := array at: size.             "your old inst var value"
 newArray at: size  put: 0.                "tvFlags"
 newArray at: size + 1 put: nil.         "OA spare"
 newArray at: size + 2 put: val.        "your iv"
 ^newArray

nb I _HAVEN'T_ actually tried this so it may need a bit of adjustment!

I remember someone (Chris Uppal maybe?) mentioning this sort of problem
(OA modifying the class shape of a superclass that you've subclassed)
but can't recollect if any solution was found.

I hope that all makes sense?  If it doesn't work (and nobody else posts
some corrected code) then I'll try to have another look tomorrow.

--
Ian