[squeak-dev] The Inbox: ShoutCore-ul.65.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Wed Jul 10 09:04:35 UTC 2019


Hi Levente,

hmmm... I think the styler should silently discard the results then.

Okay, if the view became nil somehow, there shouldn't be too many debuggers anyway. So, it's unlikely and not even risky for the entire environment if it would happen. Well, messing around with instances of styler might not be as dangerous as is fiddling in the caverns of text rendering. :-)

So, just ignore my over-cautious thoughts on this ifNil:-check on "view". Thinking too hard about "exploratory" and "liveness" and "reflection" and "long-running systems" can raise too many concerns... 

Best,
Marcel
Am 10.07.2019 10:54:56 schrieb Levente Uzonyi <leves at caesar.elte.hu>:
Hi Marcel,

Thanks for the feedback.
I checked the senders of #view: and didn't see the possibility of setting
it to nil. Based on the current usage, it could even be a "constructor"
parameter.

I have the following senders in my image:
- MorphicToolBuilder >> #buildPluggableText:
- the argument will be the result of a #new send
- PBClassPreferenceView >> #textField
- the argument will be a PluggableTextMorphPlus
- PluggableTextMorphPlus >> #useDefaultStyler
- the argument will be a PluggableTextMorphPlus

By the way, what should the styler do with the styled text when view is
nil?

Levente

On Wed, 10 Jul 2019, Marcel Taeumel wrote:

> Hi Levente,
> nice! :-) For the background process, I would either closure "view" or check for nil because any do-it in the UI process might re-configure the styler. 
>
> Best,
> Marcel
>
> Am 09.07.2019 23:00:45 schrieb commits at source.squeak.org :
>
> Levente Uzonyi uploaded a new version of ShoutCore to project The Inbox:
> http://source.squeak.org/inbox/ShoutCore-ul.65.mcz
>
> ==================== Summary ====================
>
> Name: ShoutCore-ul.65
> Author: ul
> Time: 9 July 2019, 11:00:06.496443 pm
> UUID: 5b4b23fe-b7de-4498-a16b-80959cfb1e62
> Ancestors: ShoutCore-mt.64
>
> Further SHTextStyler refactorings:
> - replaced text instance variable with temporiaries
> - removed monitor. backgroundProcess consistency is ensured by atomic execution of certain instructions
> - assume that view is never nil. It makes no sense to style when there's no view, and view is always assigned once, when a styler instance is created
>
> =============== Diff against ShoutCore-mt.64 ===============
>
> Item was changed:
> Object subclass: #SHTextStyler
> + instanceVariableNames: 'backgroundProcess view stylingEnabled'
> - instanceVariableNames: 'backgroundProcess text monitor view stylingEnabled'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'ShoutCore-Styling'!
>
> !SHTextStyler commentStamp: 'tween 8/27/2004 10:54' prior: 0!
> I am an Abstract class.
> Subclasses of me can create formatted, coloured, and styled copies of Text that is given to them.
> They may perform their styling asynchronously, in a background process which I create and manage.
>
> My public interface is...
>
> view: aViewOrMorph - set the view that will receive notifications when styling has completed.
>
> format: aText - modifies aText's string
>
> style: aText - modifies the TextAttributes of aText, but does not change the string, then sends #stylerStyled: to the view.
>
> styleInBackgroundProcess: aText - performs style: in a background process, then sends #stylerStylednBackground: to the view.
>
> styledTextFor: aText - answers a formatted and styled copy of aText
>
> unstyledTextFrom: aText - answers a copy of aText with all TextAttributes removed
>
> Subclasses of me should re-implement...
>
> privateFormat: aText - answer a formatted version of aText; the String may be changed
> privateStyle: aText - modify the TextAttributes of aText; but do not change the String
>
>
>
>
> !
>
> Item was removed:
> - ----- Method: SHTextStyler>>monitor (in category 'private') -----
> - monitor
> - ^monitor ifNil: [monitor := Monitor new]!
>
> Item was changed:
> ----- Method: SHTextStyler>>style: (in category 'styling') -----
> style: aText
> +
> + | text |
> self terminateBackgroundStylingProcess.
> + stylingEnabled ifFalse: [ ^self ].
> + text := aText copy.
> + self privateStyle: text.
> + view stylerStyled: text!
> - stylingEnabled ifTrue:[
> - text := aText copy.
> - self privateStyle: text.
> - view ifNotNil:[view stylerStyled: text] ]!
>
> Item was changed:
> ----- Method: SHTextStyler>>styleInBackgroundProcess: (in category 'styling') -----
> styleInBackgroundProcess: aText
>
> + | text newBackgroundProcess |
> self terminateBackgroundStylingProcess.
> + stylingEnabled ifFalse: [ ^self ].
> + text := aText copy.
> + newBackgroundProcess := [
> + self privateStyle: text.
> + Project current addDeferredUIMessage: [
> + view stylerStyledInBackground: text ].
> + Processor activeProcess == backgroundProcess ifTrue: [
> + backgroundProcess := nil ] ] newProcess
> + priority: Processor userBackgroundPriority;
> + yourself.
> + backgroundProcess ifNil: [
> + (backgroundProcess := newBackgroundProcess) resume ]!
> -
> - stylingEnabled ifTrue: [
> - text := aText copy.
> - self monitor critical: [
> - backgroundProcess := [
> - self privateStyle: text.
> - view ifNotNil: [:v | Project current addDeferredUIMessage: [v stylerStyledInBackground: text]].
> - ] forkAt: Processor userBackgroundPriority] ]
> - !
>
> Item was changed:
> ----- Method: SHTextStyler>>terminateBackgroundStylingProcess (in category 'private') -----
> terminateBackgroundStylingProcess
> + "Terminate the background styling process if it exists. Assume that the first two lines are executed atomically."
>
> + backgroundProcess ifNotNil: [ :backgroundProcessToTerminate |
> + backgroundProcess := nil.
> + backgroundProcessToTerminate terminate ]!
> - self monitor critical: [
> - backgroundProcess
> - ifNotNil: [
> - backgroundProcess terminate.
> - backgroundProcess := nil]].!
>
> Item was changed:
> ----- Method: SHTextStyler>>veryDeepInner: (in category 'copying') -----
> veryDeepInner: aDeepCopier
> +
> super veryDeepInner: aDeepCopier.
> + backgroundProcess := nil.
> - backgroundProcess := monitor := nil.
> - text := text veryDeepCopyWith: aDeepCopier.
> view := view veryDeepCopyWith: aDeepCopier!
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190710/431f605e/attachment.html>


More information about the Squeak-dev mailing list