Re: GTKMM PixBuff and error



On Wed, 2007-02-21 at 11:58 +0100, Xavier Larrode wrote:
> Hi all,
> 
> Is there a way when we create a PixBuf from a file,  without catching 
> the gfile_error exception, to know if the  PixBuf is fine.
> 
> Glib::RefPtr<Gdk::Pixbuf> pix = Gdk::Pixbuf::create_from_file(file);
> 
> Perhaps with the refPtr ?

Well, when you cast it to bool (such as doing "if(pix)") you'll get true
if it points to anything, false otherwise.  I guess if create_from_file
fails it probably returns a clear pointer, so it'd evaluate to false.

But I don't see how that's any easier than just using try/catch --
wouldn't using normal exception handling be generally clearer?

Regards,
John




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]