On 20/09/2012 11:27, MacArthur, Ian (SELEX GALILEO, UK) wrote:
>> On 09/19/12 10:00, Doug Parks wrote:
>>>> Fl_BMP_Image jpg("C:/Users/Marick/My Pictures/image.bmp");
>>>>
>>> After looking at my code again for the 1000th time I just realized I was
>> using an invalid file path. There is no "My Pictures" only a "Pictures"
>> folder.
>
>
>> I wonder if we could make error checking more obvious for the default
>> behavior in FLTK for this type of thing.
>>
>> I can think of three possible ways to help:
>>
>> o A global Fl::option() to control how image errors are shown
>> o An error_callback() to be called when the image can't be
>> loaded
>> o Adjust the docs + examples to include error checking
>
> Could do - though I'm a big fan of just calling access() on the path before I
> try to use it - that pretty quickly filters out any mistakes...! (And works
> on all the platforms I support too, which is handy.)
>
Yeah, I use access too - actually utf-8 version fl_access() in fl_utf8.h ;)
Also in such cases Fl_Shared_Image::get() seems to be more appropriate which
constructs image on the heap and returns 0 pointer if it fails?
Generally errors in C++ constructors are a little bit of PITA if you do not use
exceptions (which FLTK wisely avoids).
R.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk