From e160b83c452c22c651f8ed4305a7c20f17399229 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Thu, 9 Apr 2020 09:45:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=8D=D0=BA=D0=B7=D0=B5=D0=BC=D0=BF?= =?UTF-8?q?=D0=BB=D1=8F=D1=80=D0=BE=D0=B2=20=D1=81=D0=B8=D0=BD=D0=B3=D0=BB?= =?UTF-8?q?=D1=82=D0=BE=D0=BD=D0=BE=D0=B2=20=D0=BF=D0=BE=20=D1=81=D1=81?= =?UTF-8?q?=D1=8B=D0=BB=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/filesystem/01_minimal/minimal.cpp | 20 ++++++++++---------- src/myx/filesystem/paths.hpp | 4 ++-- src/myx/filesystem/paths_mt.cpp | 4 ++-- src/myx/filesystem/paths_mt.hpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/filesystem/01_minimal/minimal.cpp b/examples/filesystem/01_minimal/minimal.cpp index d43fd43..1d8e6da 100644 --- a/examples/filesystem/01_minimal/minimal.cpp +++ b/examples/filesystem/01_minimal/minimal.cpp @@ -19,18 +19,18 @@ int main( int argc, char** argv ) (void)argc; (void)argv; QCoreApplication::setApplicationName( QStringLiteral( CMLIB_PROJECT_NAME ) ); - MF::PathsMT* pathsMT = MF::PathsMT::instance(); - MF::Paths* paths = MF::Paths::instance(); + MF::PathsMT& pathsMT = MF::PathsMT::instance(); + MF::Paths& paths = MF::Paths::instance(); - pathsMT->init( QStringLiteral( CMLIB_PROJECT_NAME ), QStringLiteral( "conf" ) ); - pathsMT->findConfigFile( QStringLiteral( "test" ) ); - qDebug() << pathsMT->systemLogDirectory(); - qDebug() << pathsMT->systemConfigDirectory(); + pathsMT.init( QStringLiteral( CMLIB_PROJECT_NAME ), QStringLiteral( "conf" ) ); + pathsMT.findConfigFile( QStringLiteral( "test" ) ); + qDebug() << pathsMT.systemLogDirectory(); + qDebug() << pathsMT.systemConfigDirectory(); - paths->init( QStringLiteral( CMLIB_PROJECT_NAME ), QStringLiteral( "conf" ) ); - paths->findConfigFile( QStringLiteral( "test" ) ); - qDebug() << paths->systemConstDataDirectory(); - qDebug() << paths->configFileName(); + paths.init( QStringLiteral( CMLIB_PROJECT_NAME ), QStringLiteral( "conf" ) ); + paths.findConfigFile( QStringLiteral( "test" ) ); + qDebug() << paths.systemConstDataDirectory(); + qDebug() << paths.configFileName(); return( 0 ); } diff --git a/src/myx/filesystem/paths.hpp b/src/myx/filesystem/paths.hpp index 54b229f..ae74e79 100644 --- a/src/myx/filesystem/paths.hpp +++ b/src/myx/filesystem/paths.hpp @@ -85,10 +85,10 @@ public: * @brief getInstance * @return Уникальный экземпляр класса Paths */ - static Paths* instance() + static Paths& instance() { static Paths p; - return( &p ); + return( p ); } diff --git a/src/myx/filesystem/paths_mt.cpp b/src/myx/filesystem/paths_mt.cpp index cffebf0..76fc83e 100644 --- a/src/myx/filesystem/paths_mt.cpp +++ b/src/myx/filesystem/paths_mt.cpp @@ -13,7 +13,7 @@ namespace filesystem { PathsMT::PathsMT() = default; -PathsMT* PathsMT::instance() +PathsMT& PathsMT::instance() { volatile PathsMT* localInstance = mInstance.load( std::memory_order_acquire ); if ( localInstance == nullptr ) @@ -26,7 +26,7 @@ PathsMT* PathsMT::instance() mInstance.store( const_cast< PathsMT* >( localInstance ), std::memory_order_release ); // NOLINT } } - return( const_cast< PathsMT* >( localInstance ) ); // NOLINT + return( const_cast< PathsMT& >( *localInstance ) ); // NOLINT } } // namespace filesystem diff --git a/src/myx/filesystem/paths_mt.hpp b/src/myx/filesystem/paths_mt.hpp index 1e5a5bc..2e39e17 100644 --- a/src/myx/filesystem/paths_mt.hpp +++ b/src/myx/filesystem/paths_mt.hpp @@ -40,7 +40,7 @@ public: * @brief getInstance * @return Уникальный экземпляр класса PathsMT */ - static PathsMT* instance(); + static PathsMT& instance(); }; // class PathsMT } // namespace filesystem