[cluttermm] Script::add_search_paths(): Use std::string for filepaths.



commit ded8718c0ff17044c04890f21922abdb9f8f75ba
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Apr 11 10:25:22 2014 +0200

    Script::add_search_paths(): Use std::string for filepaths.
    
    * clutter/src/script.[hg|ccg]:
      Also avoid this g++ compiler warning:
      ISO C++ forbids variable length array 'searchPaths' [-Werror=vla]
    
      This shows the need for this patch in cogl to avoid a warning:
      https://bugzilla.gnome.org/show_bug.cgi?id=728022

 clutter/src/script.ccg |   14 ++++----------
 clutter/src/script.hg  |   10 +++++++++-
 2 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/clutter/src/script.ccg b/clutter/src/script.ccg
index 9bc8b2b..f8ce2a1 100644
--- a/clutter/src/script.ccg
+++ b/clutter/src/script.ccg
@@ -16,6 +16,7 @@
  */
 
 #include <clutter/clutter.h>
+#include <glibmm/vectorutils.h>
 
 namespace Clutter
 {
@@ -39,17 +40,10 @@ guint Script::load_from_data(const Glib::ustring& data, std::auto_ptr<Glib::Erro
   return result;
 }
 
-void Script::add_search_paths(const std::vector<Glib::ustring>& paths)
+void Script::add_search_paths(const std::vector<std::string>& paths)
 {
-  const int pathCount = paths.size();
-  const char* searchPaths[pathCount];
-
-  for(uint i = 0; i < paths.size(); ++i)
-  {
-      searchPaths[i] = paths[i].data();
-  }
-
-  clutter_script_add_search_paths(gobj(), searchPaths, paths.size());
+  clutter_script_add_search_paths(gobj(),
+    Glib::ArrayHandler<std::string>::vector_to_array(paths).data(), paths.size());
 }
 
 std::vector<Glib::RefPtr<Glib::Object> > Script::list_objects()
diff --git a/clutter/src/script.hg b/clutter/src/script.hg
index 86007c9..ebdc87a 100644
--- a/clutter/src/script.hg
+++ b/clutter/src/script.hg
@@ -46,8 +46,16 @@ public:
 #endif
   _WRAP_METHOD(guint load_from_file(const std::string& filename), clutter_script_load_from_file, errthrow)
 
+  /** Adds paths to the list of search paths held by the Script .
+   * The search paths are used by lookup_filename(), which can be used to define
+   * search paths for the textures source file name or other custom, file-based
+   * properties.
+   *
+   * @param Search paths.
+   */
+  void add_search_paths(const std::vector<std::string>& paths);
   _IGNORE(clutter_script_add_search_paths)
-  void add_search_paths(const std::vector<Glib::ustring>& paths);
+
   _WRAP_METHOD(Glib::ustring lookup_filename(const Glib::ustring& filename), clutter_script_lookup_filename)
 
   /** Get a RefPtr to an object from the ClutterScript JSON file.


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