<div dir="auto">hmm. I didn't notice the use of TimeStamp. We should stop using that subclass where possible and not include any new uses in the base image. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 4, 2019, 09:39 Chris Cunningham <<a href="mailto:cunningham.cb@gmail.com">cunningham.cb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi.<div><br><div>I like the changes (especially the switch to DateAndTime), however, if you have a FrameRateMorph open when updating, it raises errors and fails to work (the time to timestamp gives it issues).</div></div><div><br></div><div>Any chance you could prescript to fix this? Maybe either update existing instances with DateAndTimes and stop/start stepping around the update, or closing all instances (although I'm not sure if that is advisable with the comments about 'stand-alone entity' in initializeToStandAlone, which implies there are embedded instances).</div><div><br></div><div>-cbc</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 4, 2019 at 6:54 AM <<a href="mailto:commits@source.squeak.org" target="_blank" rel="noreferrer">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">A new version of MorphicExtras was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/MorphicExtras-ct.260.mcz" rel="noreferrer noreferrer" target="_blank">http://source.squeak.org/inbox/MorphicExtras-ct.260.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: MorphicExtras-ct.260<br>
Author: ct<br>
Time: 4 September 2019, 3:53:54.175698 pm<br>
UUID: cab65f78-e646-cc40-9d0f-c16114d1bb44<br>
Ancestors: MorphicExtras-mt.259<br>
<br>
Refactor FrameRateMorph: Add accessors for updateInterval and expose measure data. Use TimeStamp instead of Time to avoid clock wrap around.<br>
<br>
=============== Diff against MorphicExtras-mt.259 ===============<br>
<br>
Item was changed:<br>
StringMorph subclass: #FrameRateMorph<br>
+ instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay updateInterval mSecsPerFrame framesPerSec'<br>
- instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay'<br>
classVariableNames: ''<br>
poolDictionaries: ''<br>
category: 'MorphicExtras-Demo'!<br>
<br>
Item was added:<br>
+ ----- Method: FrameRateMorph>>framesPerSec (in category 'accessing') -----<br>
+ framesPerSec<br>
+ <br>
+ ^ framesPerSec!<br>
<br>
Item was changed:<br>
----- Method: FrameRateMorph>>initialize (in category 'initialization') -----<br>
initialize<br>
"initialize the state of the receiver"<br>
super initialize.<br>
""<br>
+ lastDisplayTime := TimeStamp new.<br>
- lastDisplayTime := 0.<br>
framesSinceLastDisplay := 0.<br>
+ self updateInterval: 500 milliSeconds.<br>
self font: (Preferences standardMenuFont emphasized: 1).<br>
!<br>
<br>
Item was added:<br>
+ ----- Method: FrameRateMorph>>mSecsPerFrame (in category 'accessing') -----<br>
+ mSecsPerFrame<br>
+ <br>
+ ^ mSecsPerFrame!<br>
<br>
Item was changed:<br>
----- Method: FrameRateMorph>>step (in category 'stepping and presenter') -----<br>
step<br>
"Compute and display (every half second or so) the current framerate"<br>
<br>
+ | now timePassed newContents |<br>
- | now mSecs mSecsPerFrame framesPerSec newContents |<br>
framesSinceLastDisplay := framesSinceLastDisplay + 1.<br>
+ now := TimeStamp now.<br>
+ timePassed := now - lastDisplayTime.<br>
+ (timePassed > self updateInterval) ifTrue: <br>
+ [| mSecs |<br>
+ mSecs := timePassed asMilliSeconds.<br>
+ mSecsPerFrame := mSecs // framesSinceLastDisplay.<br>
- now := Time millisecondClockValue.<br>
- mSecs := now - lastDisplayTime.<br>
- (mSecs > 500 or: [mSecs < 0 "clock wrap-around"]) ifTrue: <br>
- [mSecsPerFrame := mSecs // framesSinceLastDisplay.<br>
framesPerSec := (framesSinceLastDisplay * 1000) // mSecs.<br>
newContents := mSecsPerFrame printString, ' mSecs (', framesPerSec printString, ' frame', (framesPerSec = 1 ifTrue: [''] ifFalse: ['s']), '/sec)'.<br>
self contents: newContents.<br>
lastDisplayTime := now.<br>
framesSinceLastDisplay := 0]<br>
ifFalse:<br>
["Ensure at least one pixel is drawn per frame"<br>
Preferences higherPerformance ifTrue: [self invalidRect: (self position extent: 1@1)]]!<br>
<br>
Item was added:<br>
+ ----- Method: FrameRateMorph>>updateInterval (in category 'accessing') -----<br>
+ updateInterval<br>
+ <br>
+ ^ updateInterval!<br>
<br>
Item was added:<br>
+ ----- Method: FrameRateMorph>>updateInterval: (in category 'accessing') -----<br>
+ updateInterval: aNumber<br>
+ <br>
+ updateInterval := aNumber!<br>
<br>
<br>
</blockquote></div>
</blockquote></div>