Re: Glib::get_system_data_dirs() returns no useful result



2012/4/17 Mateusz Marzantowicz <mmarzantowicz osdf com pl>:
> Hello,
>
> I was trying to use Glib::get_system_data_dirs() function which is a
> wrapper over GTK+ function: g_get_system_data_dirs().
>
> GTK+ function works as expected and returns correct results (paths), the
> glibmm C++ version returns empty vector (size() method on this vector == 0).
>
> After fighting some time, I checked the source code of glibmm library
> and I'm now confused. Below is an extract form file:
> glib/glibmm/miscutils.cc, lines 124-139 :
>
> --- START CODE ---
> std::vector<std::string> get_system_data_dirs()
> {
>  //TODO: Use a utility function:
>  std::vector<std::string> result;
>  const char* const * cresult = g_get_system_data_dirs();
>  if(cresult)
>    return result;
>
>  for(const gchar* const * iter = cresult; *iter != 0; ++iter)
>  {
>    result.push_back(
>      convert_const_gchar_ptr_to_stdstring(*iter));
>  }
>
>  return result;
> }
> --- END CODE ---
>
> Now it is clear to me why it is not working as expected. The first if
> checks for cresult being not null but returns empty result which never
> at that point would contain data from g_get_system_data_dirs().
>
> Because I'm new to GTK+ and gtkmm/glibmm, sorry if the answer is obvious
> but why the hell is this code like this? Maybe this function should be
> used in some special manner that I'm not aware of?

Seemingly this function was not used so often that no one noticed it
before or didn't bother to ask about it or file a bug. Just a classic
case of typo + copypasta.

Fixed in master:
http://git.gnome.org/browse/glibmm/commit/?id=64b20b098dd24aeb6cea9b95ea861ddd58fde778

>
> Mateusz Marzantowicz
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list


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