[FIX] [BUG] (sm) BitmapFillGrabFormFix

Peace Jerome peace_the_dreamer at yahoo.com
Mon Mar 15 01:03:04 UTC 2004


Problem: If a zero area form is grabbed problems
arise. This fixes the problem when the user chooses to
supply his own bitmap fill from the screen. This is a
partial fix for a larger problem which I leave to the
experts to choose a solution to.

 
Form fromUser causes a lot of down the line problems.

Most methods use the form supplied without checking to
see if the user might have balked. If the corner is
above or left of the origin fromUser returns an empty
form with zero area.  Many down the line users assume
all the forms they are given are valid. And crash in
some horrible way if they aren't. 

e.g. Circle exampleTwo. will hang (at least it did for
me when I tested it) and there is no report or debug
window to tell what happened.


Question for the experts: What should Form fromUser do
when a user balks? Rectangle fromUser gives a zero
area rectangle if the corner is higher left than the
origin.

Right now it returns a Form object with zero area.
Most things that use form assume that this won't
happen. I fixed BitmapFill cause I needed it for my
other work but there are a lot of other places this
comes up. 


Rather than return a zero area form, should Form
fromUser: 


1) signal an error?
2) return a default Form? 
3) return the undefined object which will force the
methods that use Form fromUser to deal with it
promptly?

Second point for Testers and Bug Squashers. There are
probably many serious bugs in squeak that arise when a
user input is used by a method that assumes the
arguments its receiving are valid. Someone
knowledgeable and clever should be able find methods
that leap before they check.  

Can you write an inspector to check if a parameter is
stored without being checked?

Can you set a bunch of eyes to look for the cases
where these things occur? Seems to me there must be a
lot of cases and this would be a good thing to sic
newbee apprentice bugsquashers on. A chance to do
something useful while they learn the language and the
code.


 
Yours in service,  Jerome Peace


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com
--0-1522873506-1079312584=:9452
Content-Type: text/plain; name="BitFillGrabFormFix.1.cs"
Content-Description: BitFillGrabFormFix.1.cs
Content-Disposition: inline; filename="BitFillGrabFormFix.1.cs"

'From Squeak3.7alpha of 11 September 2003 [latest update: #5816] on 13 March 2004 at 6:20:31 pm'!
"Change Set:		GrabFormFix
Date:			13 March 2004
Author:			wiz (Jerome Peace)

Insure form is valid before using it.
 
Form fromUser causes a lot of down the line problems.

Most methods use the form supplied without checking to see if the user might have balked. If the corner is above or left of the origin fromUser returns an empty form with zero area.  Many down the line users assume all the forms they are given are valid. And crash in some horrible way if they aren't. 

Might be better for fromUser to return a undefined object and catch the problem early?--wiz"!


!BitmapFillStyle methodsFor: 'Morphic menu' stamp: 'wiz 3/13/2004 18:08'!
grabNewGraphicIn: aMorph event: evt
	"Used by any morph that can be represented by a graphic"
	| fill | 
	fill  _ Form fromUser.
	fill height * fill width = 0 ifTrue: [^ self].
	self form: fill. "Insure form is valid before using it. --wiz"
	self direction: self form width @ 0.
	self normal: 0 @ self form height.
	aMorph changed.! !


More information about the Squeak-dev mailing list