From 2379b944734c45c977225ea788dc1bf4e57fcb9c Mon Sep 17 00:00:00 2001 From: casey Date: Sun, 11 Sep 2016 11:33:00 -0700 Subject: [PATCH] Fixed a couple memory leaks where adapters were not being properly deleted. --- src/musikbox/app/window/OutputWindow.cpp | 3 ++- src/musikbox/app/window/TrackListView.cpp | 18 +++++++----------- src/musikbox/app/window/TrackListView.h | 1 + 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/musikbox/app/window/OutputWindow.cpp b/src/musikbox/app/window/OutputWindow.cpp index 735bb7e23..47d22ddeb 100755 --- a/src/musikbox/app/window/OutputWindow.cpp +++ b/src/musikbox/app/window/OutputWindow.cpp @@ -53,7 +53,8 @@ OutputWindow::OutputWindow(IWindow *parent) } OutputWindow::~OutputWindow() { - + delete this->adapter; + this->adapter = nullptr; } IScrollAdapter& OutputWindow::GetScrollAdapter() { diff --git a/src/musikbox/app/window/TrackListView.cpp b/src/musikbox/app/window/TrackListView.cpp index 0ff6477df..87a643c3c 100755 --- a/src/musikbox/app/window/TrackListView.cpp +++ b/src/musikbox/app/window/TrackListView.cpp @@ -59,10 +59,10 @@ using namespace cursespp; static IScrollAdapter::EntryPtr MISSING_ENTRY = IScrollAdapter::EntryPtr(); TrackListView::TrackListView( - PlaybackService& playback, + PlaybackService& playback, LibraryPtr library, RowFormatter formatter) -: ListWindow(NULL) +: ListWindow(nullptr) , playback(playback) { this->library = library; this->library->QueryCompleted.connect(this, &TrackListView::OnQueryCompleted); @@ -79,7 +79,8 @@ TrackListView::TrackListView( } TrackListView::~TrackListView() { - + delete this->adapter; + this->adapter = nullptr; } void TrackListView::Requery(std::shared_ptr query) { @@ -171,8 +172,8 @@ size_t TrackListView::Adapter::GetEntryCount() { static std::string formatWithoutAlbum(TrackPtr track, size_t width) { std::string trackNum = text::Align( - track->GetValue(constants::Track::TRACK_NUM), - text::AlignRight, + track->GetValue(constants::Track::TRACK_NUM), + text::AlignRight, TRACK_COL_WIDTH); std::string duration = text::Align( @@ -182,7 +183,7 @@ static std::string formatWithoutAlbum(TrackPtr track, size_t width) { std::string artist = text::Align( track->GetValue(constants::Track::ARTIST), - text::AlignLeft, + text::AlignLeft, ARTIST_COL_WIDTH); int titleWidth = @@ -199,11 +200,6 @@ static std::string formatWithoutAlbum(TrackPtr track, size_t width) { text::AlignLeft, titleWidth); - if (title.find("Ragat") != std::string::npos) { - int n = 10; - n++; - } - return boost::str( boost::format("%s %s %s %s") % trackNum % title % duration % artist); diff --git a/src/musikbox/app/window/TrackListView.h b/src/musikbox/app/window/TrackListView.h index 926e283eb..eca78339d 100755 --- a/src/musikbox/app/window/TrackListView.h +++ b/src/musikbox/app/window/TrackListView.h @@ -83,6 +83,7 @@ namespace musik { class Adapter : public cursespp::ScrollAdapterBase { public: Adapter(TrackListView &parent); + virtual ~Adapter() { } virtual size_t GetEntryCount(); virtual EntryPtr GetEntry(size_t index);