From ea32eecf3d2fa22c87350a3b198f8c13707627c6 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 9 Jul 2014 11:03:21 +1000 Subject: [PATCH] Fix Searchpath::operator+ to return by value rather than reference and not modify *this ladspa_search_path was the only function using this API and it is unaffected by the change --- libs/pbd/pbd/search_path.h | 4 ++-- libs/pbd/search_path.cc | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/libs/pbd/pbd/search_path.h b/libs/pbd/pbd/search_path.h index 86ab5cdc64..74ac764dc0 100644 --- a/libs/pbd/pbd/search_path.h +++ b/libs/pbd/pbd/search_path.h @@ -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. diff --git a/libs/pbd/search_path.cc b/libs/pbd/search_path.cc index 44438cc85c..1d931a546d 100644 --- a/libs/pbd/search_path.cc +++ b/libs/pbd/search_path.cc @@ -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&