Fixed a couple memory leaks where adapters were not being properly deleted.

This commit is contained in:
casey 2016-09-11 11:33:00 -07:00
parent db4b97711c
commit 2379b94473
3 changed files with 10 additions and 12 deletions

View File

@ -53,7 +53,8 @@ OutputWindow::OutputWindow(IWindow *parent)
}
OutputWindow::~OutputWindow() {
delete this->adapter;
this->adapter = nullptr;
}
IScrollAdapter& OutputWindow::GetScrollAdapter() {

View File

@ -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<TrackListQueryBase> 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);

View File

@ -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);