Glib::get_system_data_dirs() returns no useful result


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/, 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();
    return result;

  for(const gchar* const * iter = cresult; *iter != 0; ++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?

Mateusz Marzantowicz

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