ShoutCore background styling broken (FIX submitted to inbox)

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

ShoutCore background styling broken (FIX submitted to inbox)

marcel.taeumel (old)
Hi, there!

Im not exactly sure, how Squeak process scheduling works and at which points in execution time a process is interrupted, but the old implementation of background styling did not work in all cases:

SHTextStyler>>styleInBackgroundProcess: aText

        self terminateBackgroundStylingProcess.
        stylingEnabled ifTrue:[
                text := aText copy.
                self monitor critical: [
                        sem := Semaphore new.
                        [sem notNil
                                ifTrue: [
                                        sem wait.
                                        view ifNotNil:[view stylerStyledInBackground: text]]
                        ] forkAt: Processor activePriority.
                        backgroundProcess :=
                                [self privateStyle: text.
                                sem signal]
                                        forkAt: Processor userBackgroundPriority] ]

Especially for very long methods (700 lines auto-generated in my case), #stylerStyledInBackground: was not executed in a safe way.

I removed the semaphore and used appropriate Morphic data structures:

SHTextStyler>>styleInBackgroundProcess: aText

        self terminateBackgroundStylingProcess.
        stylingEnabled ifTrue:[
                text := aText copy.
                self monitor critical: [
                        backgroundProcess := [
                                self privateStyle: text.
                                view ifNotNil: [:v |
                                        WorldState addDeferredUIMessage: [v stylerStyledInBackground: text]].
                        ] forkAt: Processor userBackgroundPriority] ].

It seems to work now. I submitted it to the inbox. As a drawback, it adds a dependecy to Morphic. Well...

Best,
Marcel