My build_filename() patch

View: New views
6 Messages — Rating Filter:   Alert me  

My build_filename() patch

by Fabrício Godoy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I submited a patch in #599578[1].
Thanks.

References:
1- https://bugzilla.gnome.org/show_bug.cgi?id=599578

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: My build_filename() patch

by Mark Roberts-10 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Fabrício and list,

Fabrício wrote:

> I submited a patch in #599578[1].
> Thanks.
>
> References:
> 1- https://bugzilla.gnome.org/show_bug.cgi?id=599578

Your code includes this sort of code a few times:

   path = g_build_filename(ustr1.c_str(), ustr2.c_str(), NULLPOINTER);
   Glib::ustring r_path(path);
   g_free(path);
   return r_path;

Surely if out-of-memory, g_build_filename() will return 0 and
ustring::ustring() will throw a bad-argument exception, which the customer
will not understand. We want to throw the no-memory-exception, don't we?

All the best,
Mark
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: My build_filename() patch

by Fabrício Godoy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

2009/10/26 Mark Roberts <gtkmm@...>
Dear Fabrício and list,


Fabrício wrote:

I submited a patch in #599578[1].
Thanks.

References:
1- https://bugzilla.gnome.org/show_bug.cgi?id=599578

Your code includes this sort of code a few times:

 path = g_build_filename(ustr1.c_str(), ustr2.c_str(), NULLPOINTER);
 Glib::ustring r_path(path);
 g_free(path);
 return r_path;

Surely if out-of-memory, g_build_filename() will return 0 and ustring::ustring() will throw a bad-argument exception, which the customer will not understand. We want to throw the no-memory-exception, don't we?

All the best,
Mark

You're so right.

Unfortunately g_build_filename documentation[1] don't warns about any error.
Is there a standard way to throw exceptions into Glibmm?

Thank you.


References:
1- http://library.gnome.org/devel/glib/unstable/glib-Miscellaneous-Utility-Functions.html#g-build-filename


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: My build_filename() patch

by Armin Burgmeier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 2009-10-26 at 09:48 -0200, Fabrício Godoy wrote:

> Hi,
>
> 2009/10/26 Mark Roberts <gtkmm@...>
>         Dear Fabrício and list,
>        
>        
>        
>         Fabrício wrote:
>        
>                 I submited a patch in #599578[1].
>                 Thanks.
>                
>                 References:
>                 1- https://bugzilla.gnome.org/show_bug.cgi?id=599578
>        
>        
>         Your code includes this sort of code a few times:
>        
>          path = g_build_filename(ustr1.c_str(), ustr2.c_str(),
>         NULLPOINTER);
>          Glib::ustring r_path(path);
>          g_free(path);
>          return r_path;
>        
>         Surely if out-of-memory, g_build_filename() will return 0 and
>         ustring::ustring() will throw a bad-argument exception, which
>         the customer will not understand. We want to throw the
>         no-memory-exception, don't we?
>        
>         All the best,
>         Mark
>
> You're so right.
>
> Unfortunately g_build_filename documentation[1] don't warns about any
> error.

Maybe this is because there aren't any. I guess g_build_filename uses
g_malloc, and g_malloc abort()s the program instead of returning a
nullpointer if it runs out of memory.

Armin

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: My build_filename() patch

by Murray Cumming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 2009-10-26 at 11:24 +0100, Mark Roberts wrote:

> Dear Fabrício and list,
>
> Fabrício wrote:
>
> > I submited a patch in #599578[1].
> > Thanks.
> >
> > References:
> > 1- https://bugzilla.gnome.org/show_bug.cgi?id=599578
>
> Your code includes this sort of code a few times:
>
>    path = g_build_filename(ustr1.c_str(), ustr2.c_str(), NULLPOINTER);
>    Glib::ustring r_path(path);
>    g_free(path);
>    return r_path;

We have these (inline) utility functions to simplify this:
  Glib::convert_const_gchar_ptr_to_ustring()
  Glib::convert_return_gchar_ptr_to_ustring()
  Glib::convert_const_gchar_ptr_to_stdstring()
  Glib::convert_return_gchar_ptr_to_stdstring()

More importantly, filepaths should be std::string, not Glib::ustring,
because they are of unknown encoding.

--
murrayc@...
www.murrayc.com
www.openismus.com

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: My build_filename() patch

by Fabrício Godoy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bug #599578 updated.

2009/10/26 Murray Cumming <murrayc@...>
On Mon, 2009-10-26 at 11:24 +0100, Mark Roberts wrote:
> Dear Fabrício and list,
>
> Fabrício wrote:
>
> > I submited a patch in #599578[1].
> > Thanks.
> >
> > References:
> > 1- https://bugzilla.gnome.org/show_bug.cgi?id=599578
>
> Your code includes this sort of code a few times:
>
>    path = g_build_filename(ustr1.c_str(), ustr2.c_str(), NULLPOINTER);
>    Glib::ustring r_path(path);
>    g_free(path);
>    return r_path;

We have these (inline) utility functions to simplify this:
 Glib::convert_const_gchar_ptr_to_ustring()
 Glib::convert_return_gchar_ptr_to_ustring()
 Glib::convert_const_gchar_ptr_to_stdstring()
 Glib::convert_return_gchar_ptr_to_stdstring()

More importantly, filepaths should be std::string, not Glib::ustring,
because they are of unknown encoding.

--
murrayc@...
www.murrayc.com
www.openismus.com




--
Evite spam use o campo Cco
http://emailfalso.blogspot.com/2009/04/voce-sabe-o-que-e-cco.html

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list