diff --git a/src/core/Library/Base.cpp b/src/core/Library/Base.cpp index f1655cdf3..eb01f1493 100644 --- a/src/core/Library/Base.cpp +++ b/src/core/Library/Base.cpp @@ -52,12 +52,21 @@ Library::Base::Base(utfstring identifier) ,queueCallbackStarted(false) ,bCurrentQueryCanceled(false) ,exit(false) - ,nowPlaying(new musik::core::tracklist::Standard()) { } musik::core::tracklist::Ptr Library::Base::NowPlaying(){ - return this->nowPlaying; + if(tracklist::Ptr tracklist = this->nowPlaying.lock()){ + return tracklist; + } + + tracklist::Ptr tracklist(new musik::core::tracklist::Standard()); + this->nowPlaying = tracklist; + + if(LibraryPtr thisPtr = this->self.lock()){ + tracklist->SetLibrary(thisPtr); + } + return tracklist; } Library::Base::~Base(void){ diff --git a/src/core/Library/Base.h b/src/core/Library/Base.h index ada5f9e98..5d5ac8fa0 100644 --- a/src/core/Library/Base.h +++ b/src/core/Library/Base.h @@ -37,6 +37,7 @@ #pragma once #include +#include ////////////////////////////////////////////////////////////////////////////// // Forward declare namespace musik{ namespace core{ @@ -50,6 +51,7 @@ namespace musik{ namespace core{ class Base; } typedef boost::shared_ptr LibraryPtr; + typedef boost::weak_ptr LibraryWeakPtr; } } ////////////////////////////////////////////////////////////////////////////// @@ -86,8 +88,9 @@ namespace musik{ namespace core{ namespace Library{ ///musik::core::Library::LocalDB ////////////////////////////////////////// class Base : boost::noncopyable{ - public: + protected: Base(utfstring identifier); + public: virtual ~Base(void); ////////////////////////////////////////// @@ -259,10 +262,11 @@ class Base : boost::noncopyable{ bool exit; boost::condition waitCondition; - musik::core::tracklist::Ptr nowPlaying; + musik::core::tracklist::WeakPtr nowPlaying; public: boost::mutex libraryMutex; + LibraryWeakPtr self; }; @@ -273,4 +277,5 @@ class Base : boost::noncopyable{ namespace musik{ namespace core{ typedef boost::shared_ptr LibraryPtr; + typedef boost::weak_ptr LibraryWeakPtr; } } diff --git a/src/core/Library/LocalDB.cpp b/src/core/Library/LocalDB.cpp index a6e7efcdf..a40df35d3 100644 --- a/src/core/Library/LocalDB.cpp +++ b/src/core/Library/LocalDB.cpp @@ -58,6 +58,12 @@ Library::LocalDB::LocalDB(utfstring identifier) { } +LibraryPtr Library::LocalDB::Create(utfstring identifier){ + LibraryPtr lib(new Library::LocalDB(identifier)); + lib->self = lib; + return lib; +} + Library::LocalDB::~LocalDB(void){ this->Exit(); this->threads.join_all(); diff --git a/src/core/Library/LocalDB.h b/src/core/Library/LocalDB.h index 3fa3f92c9..de71acedb 100644 --- a/src/core/Library/LocalDB.h +++ b/src/core/Library/LocalDB.h @@ -69,9 +69,11 @@ namespace musik{ namespace core{ namespace Library{ ///Indexer ////////////////////////////////////////// class LocalDB : public Library::Base{ + private: + LocalDB(utfstring identifier); public: // Methods: - LocalDB(utfstring identifier); + static LibraryPtr Create(utfstring identifier); ~LocalDB(void); bool Startup(); @@ -96,6 +98,7 @@ class LocalDB : public Library::Base{ ////////////////////////////////////////// musik::core::Indexer indexer; + }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/Library/Remote.cpp b/src/core/Library/Remote.cpp index 45ece1761..31c013aed 100644 --- a/src/core/Library/Remote.cpp +++ b/src/core/Library/Remote.cpp @@ -63,6 +63,12 @@ Library::Remote::Remote(utfstring identifier) { } +LibraryPtr Library::Remote::Create(utfstring identifier){ + LibraryPtr lib(new Library::Remote(identifier)); + lib->self = lib; + return lib; +} + Library::Remote::~Remote(void){ this->Exit(); this->threads.join_all(); diff --git a/src/core/Library/Remote.h b/src/core/Library/Remote.h index 7900e87fe..870a0e216 100644 --- a/src/core/Library/Remote.h +++ b/src/core/Library/Remote.h @@ -58,9 +58,11 @@ namespace musik{ namespace core{ namespace Library{ ///Library used for your remote music. ////////////////////////////////////////// class Remote : public Library::Base{ + private: + Remote(utfstring identifier); public: // Methods: - Remote(utfstring identifier); + static LibraryPtr Create(utfstring identifier); ~Remote(void); bool Startup(); diff --git a/src/core/LibraryFactory.cpp b/src/core/LibraryFactory.cpp index 2fbce98cd..f7625b483 100644 --- a/src/core/LibraryFactory.cpp +++ b/src/core/LibraryFactory.cpp @@ -79,10 +79,10 @@ void LibraryFactory::AddLibrary(utfstring name,int type){ LibraryPtr lib; switch(type){ case Types::Remote: - lib.reset(new Library::Remote(name)); + lib = Library::Remote::Create(name); break; default: - lib.reset(new Library::LocalDB(name)); + lib = Library::LocalDB::Create(name); } if(lib){ diff --git a/src/core/PlaybackQueue.cpp b/src/core/PlaybackQueue.cpp index 71561d6da..066fee761 100644 --- a/src/core/PlaybackQueue.cpp +++ b/src/core/PlaybackQueue.cpp @@ -65,6 +65,7 @@ PlaybackQueue::PlaybackQueue(void) PlaybackQueue::~PlaybackQueue(void) { this->transport.Stop(); + this->nowPlaying.reset(); } ////////////////////////////////////////// diff --git a/src/core/pch.hpp b/src/core/pch.hpp index 217a99179..0cc6b540d 100644 --- a/src/core/pch.hpp +++ b/src/core/pch.hpp @@ -39,6 +39,8 @@ #pragma warning (disable : 4996 4018 4482) +#include + #include #include @@ -73,5 +75,4 @@ #include */ -#include diff --git a/src/core/tracklist/IRandomAccess.h b/src/core/tracklist/IRandomAccess.h index f64888736..a7e22035f 100644 --- a/src/core/tracklist/IRandomAccess.h +++ b/src/core/tracklist/IRandomAccess.h @@ -53,6 +53,7 @@ namespace musik{ namespace core{ #include #include +#include #include namespace musik{ namespace core{ @@ -96,6 +97,7 @@ namespace musik{ namespace core{ }; typedef boost::shared_ptr Ptr; + typedef boost::weak_ptr WeakPtr; } } } diff --git a/src/cube/LibraryWindowController.cpp b/src/cube/LibraryWindowController.cpp index da5f1345b..6cf6d9acf 100644 --- a/src/cube/LibraryWindowController.cpp +++ b/src/cube/LibraryWindowController.cpp @@ -87,12 +87,6 @@ void LibraryWindowController::OnViewCreated(Window* window) } - - // create sources view/controller -/* - -*/ - } void LibraryWindowController::OnResize(Window* window, Size size) @@ -100,17 +94,3 @@ void LibraryWindowController::OnResize(Window* window, Size size) RedrawLock redrawLock(&this->view); // this->clientView->Resize(this->mainWindow.ClientSize()); } -/* -void LibraryWindowController::QueryQueueStart(){ - this->LibraryCallbackTimer.ConnectToWindow(&this->mainWindow); - this->LibraryCallbackTimer.Start(); -} - -void LibraryWindowController::QueryQueueEnd(){ - this->LibraryCallbackTimer.Stop(); -} - -void LibraryWindowController::QueryQueueLoop(){ - musik::core::LibraryFactory::GetCurrentLibrary()->RunCallbacks(); -} -*/ diff --git a/src/cube/SourcesModel.cpp b/src/cube/SourcesModel.cpp index 857b43fd2..3ba047138 100644 --- a/src/cube/SourcesModel.cpp +++ b/src/cube/SourcesModel.cpp @@ -45,7 +45,6 @@ #include #include -#include #include using namespace musik::cube; diff --git a/src/cube/pch.hpp b/src/cube/pch.hpp index 68548c50b..adfcba825 100644 --- a/src/cube/pch.hpp +++ b/src/cube/pch.hpp @@ -48,6 +48,8 @@ ////////////////////////////////////////////////////////////////////////////// #pragma warning (disable : 4996 4018 4482) +#include "vld/vld.h" + #include #include #include @@ -76,8 +78,5 @@ #include #include -////////////////////////////////////////////////////////////////////////////// - -#include "vld/vld.h" //////////////////////////////////////////////////////////////////////////////