Is is not that easy :)
TRMorph already checks for a new session.
TRCanvas not, but could be done the same way - maybe. It is difficult as
TRCanvas are shared by different objects.
And it is more difficult for TRShape.

I know Igors argument against a session management in Athens for
recreating cairo resources on image start up. It is not the job of Athens.

But it is a bit different for resources created through Athens core api.
How can the user (TRShape for example) know, that a path created by
an Athens surface referes to an external resource?

The attached changeset implements a simple check for TRCanvas and
resets paths if the canvas changes. This solves the crash on
image start up.But it is not a good solution.




2014-07-31 16:23 GMT+02:00 Igor Stasenko <[email protected]>:

> The recipe is simple: isolate the code in your application in a way that
> if certain feature not available (line nativeboost), it won't put your
> image into endless exception throwing loop.
>
>
That's another story. The projects I have seen, using athens, do this with
an explicit use
on AthensCairoSurface. Is there already a way to instantiate an
AthensSurface depending on the
available libraries? And AthensBalloon and AthensCairo don't differ only in
rendering quality, so there
is no real fallback option.





>
> On 31 July 2014 16:09, Alexandre Bergel <[email protected]> wrote:
>
>> Yes, and this is a mess.
>> I’ve spent quite some time in getting the session working with Roassal2
>> and it still does not work. I would appreciate help on this.
>>
>> Alexandre
>>
>>
>> On Jul 31, 2014, at 8:58 AM, Nicolai Hess <[email protected]> wrote:
>>
>> > It looks like Trachel does not recreate athens external resources.
>> > There is an example in AthensSceneView, on how to check and reload
>> > an AthensSurface.
>> >
>> >
>> > 2014-07-31 12:51 GMT+02:00 Usman Bhatti <[email protected]>:
>> >
>> >
>> >
>> > On Thu, Jul 31, 2014 at 11:17 AM, Blondeau Vincent <
>> [email protected]> wrote:
>> > Yes it is. But I will not do
>> >
>> > TRMorph allInstances do: #delete
>> >
>> > In command line every day…
>> >
>> >
>> > It is only intended to recover your lost work in the image not for
>> everyday use :).
>> >
>> >
>> >
>> >
>> > Vincent
>> >
>> >
>> >
>> > De : Pharo-dev [mailto:[email protected]] De la part
>> de Usman Bhatti
>> > Envoyé : jeudi 31 juillet 2014 10:59
>> > À : Pharo Development List
>> > Cc : Moose-related development
>> >
>> >
>> > Objet : Re: [Pharo-dev] Pharo image corruption and fatal VM error with
>> Roassal
>> >
>> >
>> >
>> > This may be related to this known issue reported a few days back.
>> >
>> > https://code.google.com/p/moose-technology/issues/detail?id=1084
>> >
>> >
>> >
>> > And there is a possible solution to recover your image.
>> >
>> >
>> >
>> > usman
>> >
>> >
>> >
>> > On Thu, Jul 31, 2014 at 10:50 AM, Blondeau Vincent <
>> [email protected]> wrote:
>> >
>> > Hi,
>> >
>> >
>> >
>> > Yesterday, I was using GraphET (a part of Roassal) to do some charts
>> and, today, when I wanted to reopen the image.
>> >
>> > And I got that :
>> >
>> > <image001.png>
>> >
>> > It is *very* unpleasant…
>> >
>> >
>> >
>> > To reproduce the bug:
>> >
>> > 1 - You can do either:
>> >
>> >                                 | builder |
>> >
>> >                                 builder := GET2Line data: (0 to: 100) .
>> >
>> >                                 builder
>> >
>> >                                                 y: [ :x | x*x ].
>> >
>> >
>> >
>> >                                 builder open.
>> >
>> > Or
>> >
>> > WorldMenu -> Roassal examples -> choose an item -> click on a graph . A
>> TRMorph should be opened.
>> >
>> > 2 - don’t close the graph and save the pharo image.
>> >
>> > 3 – Close the pharo image
>> >
>> > 4 - Reopen it
>> >
>> >
>> >
>> > I am under W7 x64 with the latest moose image and the VM available on
>> the pharo.org website (http://files.pharo.org/platform/Pharo3.0-win.zip)
>> from the 10 july.
>> >
>> > You will find the crash dump attached.
>> >
>> >
>> >
>> >
>> >
>> > Thankfully, I managed to open the image with a latest VM (
>> http://www.mirandabanda.org/files/Cog/VM/VM.r3056/cogwin-14.29.3056.zip).
>> >
>> > Thanks a lot Eliot ! :)
>> >
>> >
>> >
>> > And I got this:
>> >
>> > <image002.png>
>> >
>> >
>> >
>> > Thanks in advance
>> >
>> >
>> >
>> > Cheers,
>> >
>> > Vincent BLONDEAU
>> >
>> >
>> >
>> >
>> >
>> >
>> > Ce message et les pièces jointes sont confidentiels et réservés à
>> l'usage exclusif de ses destinataires. Il peut également être protégé par
>> le secret professionnel. Si vous recevez ce message par erreur, merci d'en
>> avertir immédiatement l'expéditeur et de le détruire. L'intégrité du
>> message ne pouvant être assurée sur Internet, la responsabilité de
>> Worldline ne pourra être recherchée quant au contenu de ce message. Bien
>> que les meilleurs efforts soient faits pour maintenir cette transmission
>> exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et
>> sa responsabilité ne saurait être recherchée pour tout dommage résultant
>> d'un virus transmis.
>> >
>> > This e-mail and the documents attached are confidential and intended
>> solely for the addressee; it may also be privileged. If you receive this
>> e-mail in error, please notify the sender immediately and destroy it. As
>> its integrity cannot be secured on the Internet, the Worldline liability
>> cannot be triggered for the message content. Although the sender endeavours
>> to maintain a computer virus-free network, the sender does not warrant that
>> this transmission is virus-free and will not be liable for any damages
>> resulting from any virus transmitted.
>> >
>> >
>> >
>> >
>> >
>> > Ce message et les pièces jointes sont confidentiels et réservés à
>> l'usage exclusif de ses destinataires. Il peut également être protégé par
>> le secret professionnel. Si vous recevez ce message par erreur, merci d'en
>> avertir immédiatement l'expéditeur et de le détruire. L'intégrité du
>> message ne pouvant être assurée sur Internet, la responsabilité de
>> Worldline ne pourra être recherchée quant au contenu de ce message. Bien
>> que les meilleurs efforts soient faits pour maintenir cette transmission
>> exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et
>> sa responsabilité ne saurait être recherchée pour tout dommage résultant
>> d'un virus transmis.
>> >
>> > This e-mail and the documents attached are confidential and intended
>> solely for the addressee; it may also be privileged. If you receive this
>> e-mail in error, please notify the sender immediately and destroy it. As
>> its integrity cannot be secured on the Internet, the Worldline liability
>> cannot be triggered for the message content. Although the sender endeavours
>> to maintain a computer virus-free network, the sender does not warrant that
>> this transmission is virus-free and will not be liable for any damages
>> resulting from any virus transmitted.
>> >
>> >
>> > _______________________________________________
>> > Moose-dev mailing list
>> > [email protected]
>> > https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>> --
>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>> Alexandre Bergel  http://www.bergel.eu
>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>>
>>
>>
>>
>>
>
>
> --
> Best regards,
> Igor Stasenko.
>
'From Pharo3.0 of 18 March 2013 [Latest update: #30852] on 31 July 2014 at 
10:35:55.868824 pm'!
TRObject subclass: #TRCanvas
        instanceVariableNames: 'canvas shapes fixedShapes extent animations 
morph camera announcer color session '
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Trachel-Core'!

!TRShape methodsFor: 'accessing' stamp: 'NicolaiHess 7/31/2014 22:28'!
canvas: aSurface
        "aCanvas is a AthensCairoSurface"
        canvas := aSurface.
        self resetPath.! !


!TRCanvas methodsFor: 'initialization' stamp: 'NicolaiHess 7/31/2014 22:29'!
initialize
        super initialize.
        extent := 500 @ 500.
        canvas := AthensCairoSurface extent: extent.
        session := Smalltalk session.
        shapes := OrderedCollection new.
        fixedShapes := OrderedCollection new.
        animations := OrderedCollection new.
        camera := TRCamera forCanvas: self.
        color := Color white.! !

!TRCanvas methodsFor: 'session management' stamp: 'NicolaiHess 7/31/2014 22:30'!
initializeForNewSession

        self createSurface.
        session := Smalltalk session.
! !

!TRCanvas methodsFor: 'session management' stamp: 'NicolaiHess 7/31/2014 22:30'!
checkSession

        session == Smalltalk session ifFalse: [ 
                self initializeForNewSession
                 ]! !

!TRCanvas methodsFor: 'session management' stamp: 'NicolaiHess 7/31/2014 22:31'!
createSurface
        canvas := AthensCairoSurface extent: self extent asIntegerPoint.
        self shapes do:[:s | s canvas: self].
        self fixedShapes do:[:s | s canvas: self].      
! !


!TRMorph methodsFor: 'drawing' stamp: 'NicolaiHess 7/31/2014 22:32'!
"protocol: drawing"
drawOn: aCanvas
        "aCanvas is a FormCanvas"
        
        self checkSession.
        trachelCanvas checkSession.
        
        aCanvas fillRectangle: bounds color: trachelCanvas color.
        trachelCanvas playAnimations.
        
        "The drawing has to be done when a change in the shapes occured or when 
there is an animation."
        surface drawDuring: [:cs |
                surface clear.
                
                "We display the elements that are subject to the camera"
                cs pathTransform
                        translateBy: self extent / 2;
                            scaleBy: trachelCanvas camera scale asFloat;
                        translateBy: trachelCanvas camera position negated.
                trachelCanvas shapes do: [ :trachelShape |
                        trachelShape drawOn: cs.
                ].
        
                "We display the elements that are _NOT_ subject to the camera"
                cs pathTransform loadIdentity.
                trachelCanvas fixedShapes do: [ :trachelShape |
                        trachelShape drawOn: cs.
                ].
        ].
        "aCanvas translucentImage: surface asForm at: self bounds origin."
        "asForm creates a new Form, which is likely to be expensive. This can 
be cached"
        aCanvas image: surface asForm at: self bounds origin sourceRect: (0 @ 0 
extent: surface extent) rule: 34! !

TRObject subclass: #TRCanvas
        instanceVariableNames: 'canvas shapes fixedShapes extent animations 
morph camera announcer color session'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Trachel-Core'!

!TRCanvas reorganize!
(#testing isFixedShape: isMovableShape:)
(#animations numberOfAnimations animations hasAnimation animationsRemoveAll: 
playAnimations addAnimation:)
(#visitor accept:)
(#menu addMenu:callback: addMenuAsSVG:callback: addMenuAsSVG:scale:callback:)
(#accessing numberOfShapes athensCanvas numberOfFixedShapes extent 
shapeWithActionForPosition: shapeForPositionInPixels: shapes topLeft camera 
shapeForPosition: fixedShapes extent: color: 
shapeWithActionForPositionInPixels: morph color)
(#action pushAll:behindAll: clean firstElementOf: push:behindAll:)
(#events announcer: announcer when:do: announce:)
(#initialization initialize)
(#'instance creation' buildMorph morphClass openInWindowSized: open 
openInWindowSized:titled: openTitled:)
(#updating signalUpdate)
(#building buildCircleFrom:to:color: addFixedShape: buildRectangle:color: 
buildLineFrom:to:color: privateAdd: 
buildArcAlphaAngle:betaAngle:innerRadius:externalRadius: removeShape: addShape:)
(#'session management' initializeForNewSession checkSession createSurface)
(#actions focusOnCenterScaled push:behind: setAsFixed: pushBack: pushFront: 
removeFixedShape:)
!

Reply via email to