From 38207e4ea741a5176ac3ac0810cce46b755ff8c5 Mon Sep 17 00:00:00 2001 From: Michael Kuc Date: Thu, 14 May 2020 11:40:38 +0100 Subject: [PATCH] Replace deprecated std::auto_ptr with new std::unique_ptr. --- .../MilkdropPresetFactory/IdlePreset.cpp | 6 +++--- .../MilkdropPresetFactory/IdlePreset.hpp | 2 +- .../MilkdropPresetFactory.cpp | 4 ++-- .../MilkdropPresetFactory.hpp | 2 +- .../libprojectm/MilkdropPresetFactory/Parser.cpp | 14 +++++++------- 3rdparty/libprojectm/PresetChooser.hpp | 8 ++++---- 3rdparty/libprojectm/PresetFactory.hpp | 2 +- 3rdparty/libprojectm/PresetLoader.cpp | 4 ++-- 3rdparty/libprojectm/PresetLoader.hpp | 4 ++-- 3rdparty/libprojectm/projectM.cpp | 6 ++++-- 3rdparty/libprojectm/projectM.hpp | 6 +++--- 11 files changed, 30 insertions(+), 28 deletions(-) diff --git a/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.cpp b/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.cpp index 5a48532ee..d451276aa 100644 --- a/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.cpp +++ b/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.cpp @@ -197,13 +197,13 @@ return out.str(); } -std::auto_ptr IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs) +std::unique_ptr IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs) { if (name == IDLE_PRESET_NAME) { std::istringstream in(presetText()); - return std::auto_ptr(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs)); + return std::unique_ptr(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs)); } else - return std::auto_ptr(0); + return std::unique_ptr(nullptr); } diff --git a/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.hpp b/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.hpp index 3231d4340..a3fd004be 100644 --- a/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.hpp +++ b/3rdparty/libprojectm/MilkdropPresetFactory/IdlePreset.hpp @@ -12,7 +12,7 @@ class IdlePresets { public: /// Allocate a new idle preset instance /// \returns a newly allocated auto pointer of an idle preset instance - static std::auto_ptr allocate(const std::string & path, PresetOutputs & outputs); + static std::unique_ptr allocate(const std::string & path, PresetOutputs & outputs); private: static std::string presetText(); static const std::string IDLE_PRESET_NAME; diff --git a/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.cpp b/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.cpp index 67af5349f..7cb71a32b 100644 --- a/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.cpp +++ b/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.cpp @@ -212,7 +212,7 @@ PresetOutputs* MilkdropPresetFactory::createPresetOutputs(int gx, int gy) } -std::auto_ptr MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) { +std::unique_ptr MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) { PresetOutputs *presetOutputs = _usePresetOutputs ? _presetOutputs : _presetOutputs2; @@ -223,5 +223,5 @@ std::auto_ptr MilkdropPresetFactory::allocate(const std::string & url, c if (PresetFactory::protocol(url, path) == PresetFactory::IDLE_PRESET_PROTOCOL) { return IdlePresets::allocate(path, *presetOutputs); } else - return std::auto_ptr(new MilkdropPreset(url, name, *presetOutputs)); + return std::unique_ptr(new MilkdropPreset(url, name, *presetOutputs)); } diff --git a/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.hpp b/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.hpp index 2a5a46afb..da0a6aeff 100644 --- a/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.hpp +++ b/3rdparty/libprojectm/MilkdropPresetFactory/MilkdropPresetFactory.hpp @@ -26,7 +26,7 @@ public: virtual ~MilkdropPresetFactory(); - std::auto_ptr allocate(const std::string & url, const std::string & name = std::string(), + std::unique_ptr allocate(const std::string & url, const std::string & name = std::string(), const std::string & author = std::string()); std::string supportedExtensions() const { return "milk prjm"; } diff --git a/3rdparty/libprojectm/MilkdropPresetFactory/Parser.cpp b/3rdparty/libprojectm/MilkdropPresetFactory/Parser.cpp index cdf8256c1..fe26ced16 100644 --- a/3rdparty/libprojectm/MilkdropPresetFactory/Parser.cpp +++ b/3rdparty/libprojectm/MilkdropPresetFactory/Parser.cpp @@ -1451,7 +1451,7 @@ InitCond * Parser::parse_init_cond(std::istream & fs, char * name, MilkdropPres if (PARSE_DEBUG) printf("parsed_init_cond: parsing initial condition value... (LINE %d)\n", line_count); /* integer value (boolean is an integer in C) */ - if ( (param->type == P_TYPE_BOOL)) + if ( param->type == P_TYPE_BOOL) { int bool_test; if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR) @@ -1462,7 +1462,7 @@ InitCond * Parser::parse_init_cond(std::istream & fs, char * name, MilkdropPres init_val.bool_val = bool_test; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR) { @@ -1578,7 +1578,7 @@ InitCond * Parser::parse_per_frame_init_eqn(std::istream & fs, MilkdropPreset * init_val.bool_val = (bool)val; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { init_val.int_val = (int)val; } @@ -1771,7 +1771,7 @@ int Parser::parse_wavecode(char * token, std::istream & fs, MilkdropPreset * pr /* integer value (boolean is an integer in C) */ - if ((param->type == P_TYPE_BOOL)) + if (param->type == P_TYPE_BOOL) { int bool_test; if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR) @@ -1782,7 +1782,7 @@ int Parser::parse_wavecode(char * token, std::istream & fs, MilkdropPreset * pr } init_val.bool_val = bool_test; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR) { @@ -1897,7 +1897,7 @@ int Parser::parse_shapecode(char * token, std::istream & fs, MilkdropPreset * p /* integer value (boolean is an integer in C) */ - if ((param->type == P_TYPE_BOOL)) + if (param->type == P_TYPE_BOOL) { int bool_test; if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR) @@ -1907,7 +1907,7 @@ int Parser::parse_shapecode(char * token, std::istream & fs, MilkdropPreset * p } init_val.bool_val = bool_test; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR) { diff --git a/3rdparty/libprojectm/PresetChooser.hpp b/3rdparty/libprojectm/PresetChooser.hpp index ab88b2a6e..f09fc79d0 100644 --- a/3rdparty/libprojectm/PresetChooser.hpp +++ b/3rdparty/libprojectm/PresetChooser.hpp @@ -40,7 +40,7 @@ public: /// \param presetInputs the preset inputs to associate with the preset upon construction /// \param presetOutputs the preset outputs to associate with the preset upon construction /// \returns an autopointer of the newly allocated preset - std::auto_ptr allocate(); + std::unique_ptr allocate(); /// Set the chooser asocciated with this iterator void setChooser(const PresetChooser & chooser); @@ -71,7 +71,7 @@ public: /// \param presetInputs the preset inputs to associate with the preset upon construction /// \param presetOutputs the preset outputs to associate with the preset upon construction /// \returns an auto pointer of the newly allocated preset - std::auto_ptr directoryIndex(std::size_t index) const; + std::unique_ptr directoryIndex(std::size_t index) const; /// Gets the number of presets last believed to exist in the preset loader's filename collection /// \returns the number of presets in the collection @@ -145,7 +145,7 @@ inline bool PresetIterator::operator ==(const PresetIterator & presetPos) const return (*presetPos == **this); } -inline std::auto_ptr PresetIterator::allocate() { +inline std::unique_ptr PresetIterator::allocate() { return _presetChooser->directoryIndex(_currentIndex); } @@ -211,7 +211,7 @@ inline bool PresetChooser::empty() const { return _presetLoader->size() == 0; } -inline std::auto_ptr PresetChooser::directoryIndex(std::size_t index) const { +inline std::unique_ptr PresetChooser::directoryIndex(std::size_t index) const { return _presetLoader->loadPreset(index); } diff --git a/3rdparty/libprojectm/PresetFactory.hpp b/3rdparty/libprojectm/PresetFactory.hpp index e9c8a4cd0..07bb30b52 100644 --- a/3rdparty/libprojectm/PresetFactory.hpp +++ b/3rdparty/libprojectm/PresetFactory.hpp @@ -31,7 +31,7 @@ public: /// \param name the preset name /// \param author the preset author /// \returns a valid preset object - virtual std::auto_ptr allocate(const std::string & url, const std::string & name=std::string(), + virtual std::unique_ptr allocate(const std::string & url, const std::string & name=std::string(), const std::string & author=std::string()) = 0; /// Returns a space separated list of supported extensions diff --git a/3rdparty/libprojectm/PresetLoader.cpp b/3rdparty/libprojectm/PresetLoader.cpp index e0afec582..ffe3ea5ee 100644 --- a/3rdparty/libprojectm/PresetLoader.cpp +++ b/3rdparty/libprojectm/PresetLoader.cpp @@ -130,7 +130,7 @@ void PresetLoader::rescan() } -std::auto_ptr PresetLoader::loadPreset ( unsigned int index ) const +std::unique_ptr PresetLoader::loadPreset ( unsigned int index ) const { // Check that index isn't insane @@ -146,7 +146,7 @@ std::auto_ptr PresetLoader::loadPreset ( unsigned int index ) const } -std::auto_ptr PresetLoader::loadPreset ( const std::string & url ) const +std::unique_ptr PresetLoader::loadPreset ( const std::string & url ) const { // Return a new autopointer to a preset diff --git a/3rdparty/libprojectm/PresetLoader.hpp b/3rdparty/libprojectm/PresetLoader.hpp index 02d43c18f..365d7704a 100644 --- a/3rdparty/libprojectm/PresetLoader.hpp +++ b/3rdparty/libprojectm/PresetLoader.hpp @@ -36,8 +36,8 @@ class PresetLoader { /// Load a preset by specifying it's unique identifier given when the preset url /// was added to this loader - std::auto_ptr loadPreset(unsigned int index) const; - std::auto_ptr loadPreset ( const std::string & url ) const; + std::unique_ptr loadPreset(unsigned int index) const; + std::unique_ptr loadPreset ( const std::string & url ) const; /// Add a preset to the loader's collection. /// \param url an url referencing the preset /// \param presetName a name for the preset diff --git a/3rdparty/libprojectm/projectM.cpp b/3rdparty/libprojectm/projectM.cpp index 336bc5a6f..7e4a4c289 100644 --- a/3rdparty/libprojectm/projectM.cpp +++ b/3rdparty/libprojectm/projectM.cpp @@ -46,6 +46,8 @@ #include "PCM.hpp" //Sound data handler (buffering, FFT, etc.) #include +#include + #include "Renderer.hpp" #include "PresetChooser.hpp" @@ -415,7 +417,7 @@ static void *thread_callback(void *prjm) { if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() > 1.0 ) { //printf("End Smooth\n"); - m_activePreset = m_activePreset2; + m_activePreset = std::move(m_activePreset2); timeKeeper->EndSmoothing(); } //printf("Normal\n"); @@ -789,7 +791,7 @@ void projectM::selectNext(const bool hardCut) { * * @param targetPreset */ -void projectM::switchPreset(std::auto_ptr & targetPreset) { +void projectM::switchPreset(std::unique_ptr & targetPreset) { #ifdef SYNC_PRESET_SWITCHES pthread_mutex_lock(&preset_mutex); diff --git a/3rdparty/libprojectm/projectM.hpp b/3rdparty/libprojectm/projectM.hpp index 5b3bc064b..e88966556 100644 --- a/3rdparty/libprojectm/projectM.hpp +++ b/3rdparty/libprojectm/projectM.hpp @@ -302,10 +302,10 @@ private: PresetChooser * m_presetChooser; /// Currently loaded preset - std::auto_ptr m_activePreset; + std::unique_ptr m_activePreset; /// Destination preset when smooth preset switching - std::auto_ptr m_activePreset2; + std::unique_ptr m_activePreset2; TimeKeeper *timeKeeper; @@ -318,7 +318,7 @@ private: Pipeline* currentPipe; -void switchPreset(std::auto_ptr & targetPreset); +void switchPreset(std::unique_ptr & targetPreset); };