diff --git a/src/library/dao/cue.h b/src/library/dao/cue.h index 83c052e831bf..796dba0493af 100644 --- a/src/library/dao/cue.h +++ b/src/library/dao/cue.h @@ -3,10 +3,10 @@ #include #include -#include #include #include "track/trackid.h" +#include "util/memory.h" class CueDAO; class Track; @@ -74,20 +74,11 @@ class Cue : public QObject { friend class CueDAO; }; -class CuePointer: public QSharedPointer { +class CuePointer: public std::shared_ptr { public: CuePointer() {} explicit CuePointer(Cue* pCue) - : QSharedPointer(pCue, deleteLater) { - } - - // TODO(uklotzde): Remove these functions after migration - // from QSharedPointer to std::shared_ptr - Cue* get() const { - return data(); - } - void reset() { - clear(); + : std::shared_ptr(pCue, deleteLater) { } private: diff --git a/src/sources/audiosource.h b/src/sources/audiosource.h index 5be790f219f3..0768ca61ad81 100644 --- a/src/sources/audiosource.h +++ b/src/sources/audiosource.h @@ -1,10 +1,9 @@ #ifndef MIXXX_AUDIOSOURCE_H #define MIXXX_AUDIOSOURCE_H -#include - #include "sources/urlresource.h" #include "util/audiosignal.h" +#include "util/memory.h" #include "util/result.h" #include "util/samplebuffer.h" @@ -231,7 +230,7 @@ class AudioSourceConfig : public AudioSignal { using AudioSignal::resetSamplingRate; }; -typedef QSharedPointer AudioSourcePointer; +typedef std::shared_ptr AudioSourcePointer; } // namespace mixxx diff --git a/src/sources/soundsource.h b/src/sources/soundsource.h index 0dcbebf683da..209e7a5c6047 100644 --- a/src/sources/soundsource.h +++ b/src/sources/soundsource.h @@ -75,11 +75,11 @@ class SoundSource: public MetadataSource, public AudioSource { const QString m_type; }; -typedef QSharedPointer SoundSourcePointer; +typedef std::shared_ptr SoundSourcePointer; template SoundSourcePointer newSoundSourceFromUrl(const QUrl& url) { - return SoundSourcePointer(new T(url)); + return std::make_shared(url); } } //namespace mixxx diff --git a/src/sources/soundsourcepluginlibrary.cpp b/src/sources/soundsourcepluginlibrary.cpp index f49566242e15..4eb7f426d7bf 100644 --- a/src/sources/soundsourcepluginlibrary.cpp +++ b/src/sources/soundsourcepluginlibrary.cpp @@ -15,7 +15,7 @@ namespace mixxx { return s_loadedPluginLibraries.value(libFilePath); } else { SoundSourcePluginLibraryPointer pPluginLibrary( - new SoundSourcePluginLibrary(libFilePath)); + std::make_shared(libFilePath)); if (pPluginLibrary->init()) { s_loadedPluginLibraries.insert(libFilePath, pPluginLibrary); return pPluginLibrary; diff --git a/src/sources/soundsourcepluginlibrary.h b/src/sources/soundsourcepluginlibrary.h index c1ea1bdaff4d..82e700a8134b 100644 --- a/src/sources/soundsourcepluginlibrary.h +++ b/src/sources/soundsourcepluginlibrary.h @@ -12,7 +12,7 @@ namespace mixxx { class SoundSourcePluginLibrary; -typedef QSharedPointer SoundSourcePluginLibraryPointer; +typedef std::shared_ptr SoundSourcePluginLibraryPointer; // Wrapper class for a dynamic library that implements the SoundSource plugin API @@ -20,6 +20,10 @@ class SoundSourcePluginLibrary { public: static SoundSourcePluginLibraryPointer load(const QString& libFilePath); + // Use load() instead of this constructor! + // The constructor has been declared 'public' only for technical reasons. + explicit SoundSourcePluginLibrary(const QString& libFilePath); + virtual ~SoundSourcePluginLibrary(); QString getFilePath() const { @@ -33,8 +37,6 @@ class SoundSourcePluginLibrary { SoundSourceProviderPointer getSoundSourceProvider() const; protected: - explicit SoundSourcePluginLibrary(const QString& libFilePath); - virtual bool init(); private: diff --git a/src/sources/soundsourceprovider.h b/src/sources/soundsourceprovider.h index 93e2c77d503d..a1279dc1279f 100644 --- a/src/sources/soundsourceprovider.h +++ b/src/sources/soundsourceprovider.h @@ -55,11 +55,11 @@ class SoundSourceProvider { virtual SoundSourcePointer newSoundSource(const QUrl& url) = 0; }; -typedef QSharedPointer SoundSourceProviderPointer; +typedef std::shared_ptr SoundSourceProviderPointer; template static SoundSourceProviderPointer newSoundSourceProvider() { - return SoundSourceProviderPointer(new T); + return std::make_shared(); } } // namespace mixxx diff --git a/src/sources/soundsourceproxy.cpp b/src/sources/soundsourceproxy.cpp index 61f14ff128a0..a0e4597eacf6 100644 --- a/src/sources/soundsourceproxy.cpp +++ b/src/sources/soundsourceproxy.cpp @@ -536,7 +536,7 @@ class AudioSourceProxy: public mixxx::AudioSource { DEBUG_ASSERT(pTrack); DEBUG_ASSERT(pAudioSource); return mixxx::AudioSourcePointer( - new AudioSourceProxy(pTrack, pAudioSource)); + std::make_shared(pTrack, pAudioSource)); } SINT seekSampleFrame(SINT frameIndex) override { diff --git a/src/test/soundproxy_test.cpp b/src/test/soundproxy_test.cpp index b4b816db91a2..b8e5a8c152fb 100644 --- a/src/test/soundproxy_test.cpp +++ b/src/test/soundproxy_test.cpp @@ -334,7 +334,7 @@ TEST_F(SoundSourceProxyTest, seekBoundaries) { // ...and verify read results mixxx::AudioSourcePointer pContReadSource(openAudioSource(filePath)); - ASSERT_TRUE(pContReadSource); + ASSERT_FALSE(!pContReadSource); ASSERT_EQ(frameOffset, pContReadSource->skipSampleFrames(frameOffset)); SampleBuffer contReadData( pContReadSource->frames2samples(kReadFrameCount)); diff --git a/src/track/track.h b/src/track/track.h index c143e8f0d898..c76cb649eb18 100644 --- a/src/track/track.h +++ b/src/track/track.h @@ -6,7 +6,6 @@ #include #include #include -#include #include "library/dao/cue.h" #include "library/coverart.h" @@ -16,13 +15,14 @@ #include "track/trackid.h" #include "track/playcounter.h" #include "track/trackmetadata.h" +#include "util/memory.h" #include "util/sandbox.h" #include "util/duration.h" #include "waveform/waveform.h" class Track; class TrackPointer; -typedef QWeakPointer TrackWeakPointer; +typedef std::weak_ptr TrackWeakPointer; class Track : public QObject { Q_OBJECT @@ -415,26 +415,17 @@ class Track : public QObject { friend class TrackDAO; }; -class TrackPointer: public QSharedPointer { +class TrackPointer: public std::shared_ptr { public: TrackPointer() {} explicit TrackPointer(const TrackWeakPointer& pTrack) - : QSharedPointer(pTrack) { + : std::shared_ptr(pTrack.lock()) { } explicit TrackPointer(Track* pTrack) - : QSharedPointer(pTrack, deleteLater) { + : std::shared_ptr(pTrack, deleteLater) { } TrackPointer(Track* pTrack, void (*deleter)(Track*)) - : QSharedPointer(pTrack, deleter) { - } - - // TODO(uklotzde): Remove these functions after migration - // from QSharedPointer to std::shared_ptr - Track* get() const { - return data(); - } - void reset() { - clear(); + : std::shared_ptr(pTrack, deleter) { } private: