<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-28 2:16 GMT+02:00 Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">On Sun, 27 Jul 2014, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Graphics-nice.298.mcz" target="_blank">http://source.squeak.org/<u></u>trunk/Graphics-nice.298.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Graphics-nice.298<br>
Author: nice<br>
Time: 27 July 2014, 4:20:11.638 pm<br>
UUID: 170cf894-37d9-4c00-adc3-<u></u>8531594246dc<br>
Ancestors: Graphics-nice.297<br>
<br>
Rather than commenting uggliness, remove it.<br>
<br>
Compatibility notes:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>From now on, DON&#39;T expect (ImageReadWriter formFromStream: yourStream) to reset yourStream. It&#39;s not its business, besides it does not work for every kind of Stream.<br>
</blockquote>
Resetting a Stream was only ever required for constructs like (ReadWriteStream with: &#39;someData&#39;) reset.<br>
But you DON&#39;T have to use a ReadWriteStream if it&#39;s just for reading. Rather use a ReadStream, this way, no reset is required.<br>
If really ReadWriteStream is what fits (why?) then you&#39;ll now have to perform the reset by yourself.<br>
</blockquote>
<br></div>
The stream will still receive #reset many times from #understandsImageFormat, #understandsImageFormat: and the instance side #on: methods.<br>
So I think this change may break #readNativeResourceFrom:.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
Levente</font></span><div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>Thanks Levente, this requires more patching and testing.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
=============== Diff against Graphics-nice.297 ===============<br>
<br>
Item was changed:<br>
 ----- Method: Form&gt;&gt;readNativeResourceFrom: (in category &#39;resources&#39;) -----<br>
 readNativeResourceFrom: byteStream<br>
        | img aStream |<br>
+       aStream := byteStream.<br>
-       (byteStream isKindOf: FileStream) ifTrue:[<br>
-               &quot;Ugly, but ImageReadWriter will send #reset which is implemented as #reopen and we may not be able to do so.&quot;<br>
-               aStream := RWBinaryOrTextStream with: byteStream contents.<br>
-       ] ifFalse:[<br>
-               aStream := byteStream.<br>
-       ].<br>
        img := [ImageReadWriter formFromStream: aStream] on: Error do:[:ex| nil].<br>
        img ifNil:[^nil].<br>
        (img isColorForm and:[self isColorForm]) ifTrue:[<br>
                | cc |<br>
                cc := img colors.<br>
                img colors: nil.<br>
                img displayOn: self.<br>
                img colors: cc.<br>
        ] ifFalse:[<br>
                img displayOn: self.<br>
        ].<br>
        img := nil.!<br>
<br>
Item was changed:<br>
 ----- Method: ImageReadWriter class&gt;&gt;formFromStream: (in category &#39;image reading/writing&#39;) -----<br>
 formFromStream: aBinaryStream<br>
        &quot;Answer a ColorForm stored on the given stream.  closes the stream&quot;<br>
        | reader readerClass form  |<br>
<br>
        readerClass := self withAllSubclasses<br>
                detect: [:subclass | subclass understandsImageFormat: aBinaryStream]<br>
                ifNone: [<br>
                        aBinaryStream close.<br>
                        ^self error: &#39;image format not recognized&#39;].<br>
+       reader := readerClass new on: aBinaryStream.<br>
-       reader := readerClass new on: aBinaryStream reset.<br>
        Cursor read showWhile: [<br>
                form := reader nextImage.<br>
                reader close].<br>
        ^ form<br>
 !<br>
<br>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div></div>