Fix Searchpath::operator+ to return by value rather than reference and not modify...
authorTim Mayberry <mojofunk@gmail.com>
Wed, 9 Jul 2014 01:03:21 +0000 (11:03 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Tue, 18 Aug 2015 05:09:44 +0000 (15:09 +1000)
ladspa_search_path was the only function using this API and it is unaffected by
the change

libs/pbd/pbd/search_path.h
libs/pbd/search_path.cc

index 86ab5cdc6409d47b749ecbc4a3c61f4db4464039..74ac764dc0b6febba25590a14947b4f6b710e933 100644 (file)
@@ -90,12 +90,12 @@ public:
        /**
         * Concatenate another Searchpath onto this.
         */
-       LIBPBD_TEMPLATE_MEMBER_API Searchpath& operator+ (const Searchpath& other);
+       LIBPBD_TEMPLATE_MEMBER_API const Searchpath operator+ (const Searchpath& other);
        
        /**
         * Add another path to the search path.
         */
-       LIBPBD_TEMPLATE_MEMBER_API Searchpath& operator+ (const std::string& directory_path);
+       LIBPBD_TEMPLATE_MEMBER_API const Searchpath operator+ (const std::string& directory_path);
 
        /**
         * Remove all the directories in path from this.
index 44438cc85c9faf78594d57497ecfaf31bc97b65b..1d931a546d93b9b83d2bf858bc964cf2523746a4 100644 (file)
@@ -124,19 +124,16 @@ Searchpath::operator+= (const std::string& directory_path)
        return *this;
 }
 
-Searchpath&
+const Searchpath
 Searchpath::operator+ (const std::string& directory_path)
 {
-       add_directory (directory_path);
-       return *this;
+       return Searchpath (*this) += directory_path;
 }
 
-Searchpath&
+const Searchpath
 Searchpath::operator+ (const Searchpath& spath)
 {
-       // concatenate paths into new Searchpath
-       insert(end(), spath.begin(), spath.end());
-       return *this;
+       return Searchpath (*this) += spath;
 }
 
 Searchpath&