GandK-Geoff
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2011
01:30 PM
BUG: roBitmap creation silently fails for non-integer types
This fails silently (just returns Invalid) if size is not an Integer (even if it has no fractional part):
I discovered this by trying to create a bitmap 1/4 the size of a previous power-of-2-sized bitmap by simply dividing each dimension by 2. Unfortunately that means the result was a floating point type, rather than the integer type I started with -- and the type change gave roBitmap's constructor indigestion.
All of which would have been no problem at all, and an easy fix. Except that CreateObject() failed silently (just returning Invalid, the same as when there is no more video memory available), and it took an extended debugging session to find the bug, because I had no idea what had gone wrong.
Can CreateObject("roBitmap", ...) please throw an exception, or at least print a warning to console, when its arguments are the wrong type?
CreateObject("roBitmap", { width: size, height: size })
I discovered this by trying to create a bitmap 1/4 the size of a previous power-of-2-sized bitmap by simply dividing each dimension by 2. Unfortunately that means the result was a floating point type, rather than the integer type I started with -- and the type change gave roBitmap's constructor indigestion.
All of which would have been no problem at all, and an easy fix. Except that CreateObject() failed silently (just returning Invalid, the same as when there is no more video memory available), and it took an extended debugging session to find the bug, because I had no idea what had gone wrong.
Can CreateObject("roBitmap", ...) please throw an exception, or at least print a warning to console, when its arguments are the wrong type?
2 REPLIES 2
RyanMarquiste
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2011
05:22 PM
Re: BUG: roBitmap creation silently fails for non-integer ty
Not a solution to the problem you've posted, but something that may help. Whenever I'm creating an roBitmap I do a check for invalid as follows:
It's somewhat like catching an exception, and it may save you some frustration in troubleshooting.
bmp = CreateObject("roBitmap", "pkg:/file.jpg")
if bmp = invalid then
print "Unable to create bitmap."
stop
end if
It's somewhat like catching an exception, and it may save you some frustration in troubleshooting.
GandK-Geoff
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2011
08:33 PM
Re: BUG: roBitmap creation silently fails for non-integer ty
"RyanMarquiste" wrote:
Not a solution to the problem you've posted, but something that may help. Whenever I'm creating an roBitmap I do a check for invalid ... It's somewhat like catching an exception, and it may save you some frustration in troubleshooting.
Sure ... and I'm checking for create failures as well. My problem is that when there is a failure, there's no way to tell why it happened -- even something as coarse as knowing if it was invalid inputs (like my wrong argument types) or a system failure (like running out of video memory). My frustration came from expecting one error class and getting the other ... and not even because of a static type failure, but a dynamic type failure caused by an unexpectedly morphing variable, so the problem didn't occur every time.