<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On 19.12.2013, at 17:38, Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Here is the code:<br><br>setExtent: extent depth: bitsPerPixel bits: bitmap<br>&nbsp;&nbsp;&nbsp; "Create a virtual bit map with the given extent and bitsPerPixel."<br><br>&nbsp;&nbsp;&nbsp; width := extent x asInteger.<br>
&nbsp;&nbsp;&nbsp; width &lt; 0 ifTrue: [width := 0].<br>&nbsp;&nbsp;&nbsp; height := extent y asInteger.<br>&nbsp;&nbsp;&nbsp; height &lt; 0 ifTrue: [height := 0].<br>&nbsp;&nbsp;&nbsp; depth := bitsPerPixel.<br>&nbsp;&nbsp;&nbsp; (bits isNil or:[self bitsSize = bitmap size]) ifFalse:[^self error:'Bad dimensions'].<br>
&nbsp;&nbsp;&nbsp; bits := bitmap<br><br></div><div>If we look at the guard for bitsSize, there are two things weird:<br><br></div><div>- the test bits isNil disengage the guard the first time this initialization is sent, that is virtually every time (did we ever tried to recycle a Form this way?)<br>
</div><div>- the test could be bitmap isNil or: [...<br></div></div></blockquote><div><br></div><div>Yes. Looks like a simple typo to me.</div><br><blockquote type="cite"><div dir="ltr"><div>but in this case we can no longer initialize a Form read from png for example (see examples in PaintBoxMorph class 'resources'), because such initialization occurs with a ByteArray...<br>
<br></div><div>So the test could be<br>&nbsp;&nbsp;&nbsp; (bitmap isNil<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or: [(bitmap class isWords and: [self bitsSize = bitmap size])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or: [bitmap class isBytes and: [self bitsSize * 4 = bitmap size]]])<br></div></div></blockquote><div><br></div><div>That looks much more like the intention.</div><br><blockquote type="cite"><div dir="ltr"><div>
(or the same with <br></div><div>but then this would forbid initialization with compressed (hibernated) ByteArray format (no idea if it is used...)</div></div></blockquote><div><br></div><div>The hibernation is pretty much private to the Form, don't think anyone would set that from the outside.</div><br><blockquote type="cite"><div dir="ltr"><div>The alternative is to completely remove the guard&nbsp; I don't know if the BitBlt primitives are protected enough from bitmap overflow, but anyway as demonstrated above the guard is not active.<br>
<br></div><div>It's always questionable to touch those parts sealed by famous predecessors (di, ar, ...).<br></div></div></blockquote><div><br></div><div>Not at all. They would readily admit to having done stupid stuff occasionally ;)</div><br><blockquote type="cite"><div dir="ltr"><div>It ain't really broken, and even Juan did not change it in Cuis.<br></div><div>But I feel like those Form have accumulated some dust and could shine a bit brighter.<br>
</div></div></blockquote><br></div><div>:)</div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; font-family: 'Lucida Grande'; font-size: 12px;"><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Helvetica; ">- Bert -</span></div><br class="Apple-interchange-newline"></span>

</div>
<br></body></html>