Problem with PackageManager>>onSystemClassRemoved:

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

Problem with PackageManager>>onSystemClassRemoved:

Keith Alcock
In porting my partially completed application from Dolphin 3 to 4, I
find that the running application triggers an assertion in
PackageManager>>onSystemClassRemoved: when it programmatically removes a
class.  It looks like pkg is nil when the method below runs and the
changed collection doesn't include nil, apparently.  The removed class
is uncommitted and was also loaded programmatically.

Some methods further up the call stack have some #todo's left and this
might be one.  I'm adding a check for nil here without knowing if that's
the real solution.  Heads up.

Keith Alcock


!PackageManager methodsFor!

onSystemClassRemoved: aClass
 "Private - React to aClass being removed from the Smalltalk system.
 Ensure that none of the packages held by the receiver refer to aClass
 or its methods now it has departed."

 self isProcessingEvents ifTrue: [ | changed pkg |
  pkg := packagedGlobals removeKey: aClass name ifAbsent: [].
  "We must inform all packages, not just the package owning the class,
   in case any other packages include loose methods of the class. In
case
  they do we empty our loose method cache."
  self forgetLooseMethods.
  changed := self packages select: [:aPackage | aPackage onClassRemoved:
aClass].
  self assert: [looseMethods isNil].
  "Modification here."
  pkg notNil ifTrue: [
   self assert: [
    changed includes: pkg.
   ].
  ].
  changed do: [:aPackage | aPackage ownedChanged].
  self resetPrerequisites].
! !


Reply | Threaded
Open this post in threaded view
|

Re: Problem with PackageManager>>onSystemClassRemoved:

Keith Alcock
However, this seems to have been fixed with patch level 1.


Keith Alcock wrote:

> In porting my partially completed application from Dolphin 3 to 4, I
> find that the running application triggers an assertion in
> PackageManager>>onSystemClassRemoved: when it programmatically removes a
> class.  It looks like pkg is nil when the method below runs and the
> changed collection doesn't include nil, apparently.  The removed class
> is uncommitted and was also loaded programmatically.
>
> Some methods further up the call stack have some #todo's left and this
> might be one.  I'm adding a check for nil here without knowing if that's
> the real solution.  Heads up.
>
> Keith Alcock
>
> !PackageManager methodsFor!
>
> onSystemClassRemoved: aClass
>  "Private - React to aClass being removed from the Smalltalk system.
>  Ensure that none of the packages held by the receiver refer to aClass
>  or its methods now it has departed."
>
>  self isProcessingEvents ifTrue: [ | changed pkg |
>   pkg := packagedGlobals removeKey: aClass name ifAbsent: [].
>   "We must inform all packages, not just the package owning the class,
>    in case any other packages include loose methods of the class. In
> case
>   they do we empty our loose method cache."
>   self forgetLooseMethods.
>   changed := self packages select: [:aPackage | aPackage onClassRemoved:
> aClass].
>   self assert: [looseMethods isNil].
>   "Modification here."
>   pkg notNil ifTrue: [
>    self assert: [
>     changed includes: pkg.
>    ].
>   ].
>   changed do: [:aPackage | aPackage ownedChanged].
>   self resetPrerequisites].
> ! !