[squeak-dev] The Inbox: ShoutCore-ct.86.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Oct 22 13:29:01 UTC 2021


A new version of ShoutCore was added to project The Inbox:
http://source.squeak.org/inbox/ShoutCore-ct.86.mcz

==================== Summary ====================

Name: ShoutCore-ct.86
Author: ct
Time: 22 October 2021, 3:28:59.928526 pm
UUID: 0053c4f7-4a73-3140-a1ff-dab36881e956
Ancestors: ShoutCore-mt.85

Fixes an issue with background styling in Shout. If a text is styled in a background process first and then styled synchronously again *before* the deferred UI message from the first run has been processed, don't publish the first version of the text to the view. See Tests-ct.466.

To make this possible, do not terminate the styling process before the UI message has been processed and check whether the process is alive when the message is being processed.

Also revises the metaphor in the private part of the styler slightly to decouple implementation from intent - rename #terminateBackgroundStylingProcess to #discardBackgroundStyling and use the terms "styling request" and "publish" in the comments.

=============== Diff against ShoutCore-mt.85 ===============

Item was added:
+ ----- Method: SHTextStyler>>discardBackgroundStyling (in category 'private') -----
+ discardBackgroundStyling
+ 	"Discard all open background styling requests if any.
+ 	Assume that the first two lines are executed atomically."
+ 
+ 	backgroundProcess ifNotNil: [ :backgroundProcessToTerminate |
+ 		backgroundProcess := nil.
+ 		backgroundProcessToTerminate terminate ]!

Item was changed:
  ----- Method: SHTextStyler>>format: (in category 'formatting') -----
  format: aText
+ 	"Answer a copy of <aText> which has been reformatted, or <aText> if no formatting is to be applied"
- 	"Answer a copy of <aText> which has been reformatted,
- 	or <aText> if no formatting is to be applied"
  	
+ 	self discardBackgroundStyling.
- 	self terminateBackgroundStylingProcess.
  	^self privateFormat: aText!

Item was changed:
  ----- Method: SHTextStyler>>style: (in category 'styling') -----
  style: aText
  	
  	| text |
+ 	self discardBackgroundStyling.
- 	self terminateBackgroundStylingProcess.
  	stylingEnabled ifFalse: [ ^self ].
  	text := aText copy.
  	self privateStyle: text.
  	view stylerStyled: text!

Item was changed:
  ----- Method: SHTextStyler>>styleInBackgroundProcess: (in category 'styling') -----
  styleInBackgroundProcess: aText
+ 	
- 
  	| text newBackgroundProcess |
+ 	self discardBackgroundStyling.
- 	self terminateBackgroundStylingProcess.
  	stylingEnabled ifFalse: [ ^self ].
  	text := aText copy.
+ 	newBackgroundProcess := nil.
+ 	newBackgroundProcess := [ | sem |
- 	newBackgroundProcess := [
  		self privateStyle: text.
+ 		sem := Semaphore new.
  		Project current addDeferredUIMessage: [
+ 			"The styling request might have been discarded in the meantime. Check that it is still relevant before publishing the result. See ShoutTest >> #testDiscardBackgroundStylingAffectsDeferredUIMessages."
+ 			newBackgroundProcess isTerminated ifFalse: [
+ 				view stylerStyledInBackground: text.
+ 				sem signal ] ].
+ 		sem wait. "Keep this process alive until the styling have been published do that #discardBackgroundStyling can also affect styling requests that are only pending for publication."
+ 		backgroundProcess := nil ] newProcess
+ 			priority: Processor userBackgroundPriority;
+ 			yourself.
+ 	backgroundProcess := newBackgroundProcess resume.!
- 			view stylerStyledInBackground: text ].
- 		Processor activeProcess == backgroundProcess ifTrue: [
- 			backgroundProcess := nil ] ] newProcess
- 		priority: Processor userBackgroundPriority;
- 		yourself.
- 	backgroundProcess ifNil: [
- 		(backgroundProcess := newBackgroundProcess) resume ]!

Item was removed:
- ----- 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 ]!



More information about the Squeak-dev mailing list