From 3573a2c431d29848148dedfdbf99d3bc65e2f2b3 Mon Sep 17 00:00:00 2001
From: Lawrence Rust <lvr@softsystem.co.uk>
Date: Tue, 26 Jun 2012 15:49:09 +0200
Subject: [PATCH] MythMusic: Fix an abort due to accessing free'd memory
When creating. editing or deleting a playlist an abort can occur
in Track::deleteYourWidget by accessing my_widget if it has been deleted
by its parent.
This patch adds a callback to Track::WidgetDeleted when the widget
is deleted and so prevents stale data.
Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
---
mythplugins/mythmusic/mythmusic/playlist.cpp | 6 ++++++
mythplugins/mythmusic/mythmusic/playlist.h | 1 +
mythplugins/mythmusic/mythmusic/treecheckitem.cpp | 6 ++++++
mythplugins/mythmusic/mythmusic/treecheckitem.h | 1 +
4 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/mythplugins/mythmusic/mythmusic/playlist.cpp b/mythplugins/mythmusic/mythmusic/playlist.cpp
index e2e8dde..0dccc26 100644
a
|
b
|
void Track::deleteYourWidget() |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
| 80 | void Track::WidgetDeleted() |
| 81 | { |
| 82 | my_widget = NULL; |
| 83 | } |
| 84 | |
| 85 | |
80 | 86 | void Track::moveUpDown(bool flag) |
81 | 87 | { |
82 | 88 | parent->moveTrackUpDown(flag, this); |
diff --git a/mythplugins/mythmusic/mythmusic/playlist.h b/mythplugins/mythmusic/mythmusic/playlist.h
index 8b3c3a3..a8c0ca2 100644
a
|
b
|
class Track |
59 | 59 | int getValue(){return index_value;} |
60 | 60 | |
61 | 61 | void deleteYourWidget(); |
| 62 | void WidgetDeleted(); |
62 | 63 | void deleteYourself(); |
63 | 64 | void moveUpDown(bool flag); |
64 | 65 | |
diff --git a/mythplugins/mythmusic/mythmusic/treecheckitem.cpp b/mythplugins/mythmusic/mythmusic/treecheckitem.cpp
index 085abea..46b902d 100644
a
|
b
|
PlaylistTrack::PlaylistTrack(UIListGenericTree *parent, const QString &title) |
193 | 193 | m_image = pixmap; |
194 | 194 | } |
195 | 195 | |
| 196 | PlaylistTrack::~PlaylistTrack() |
| 197 | { |
| 198 | if (ptr_to_owner) |
| 199 | ptr_to_owner->WidgetDeleted(); |
| 200 | } |
| 201 | |
196 | 202 | void PlaylistTrack::userSelectedMe(void) |
197 | 203 | { |
198 | 204 | } |
diff --git a/mythplugins/mythmusic/mythmusic/treecheckitem.h b/mythplugins/mythmusic/mythmusic/treecheckitem.h
index fad1535..a9060e8 100644
a
|
b
|
class PlaylistTrack : public PlaylistItem |
72 | 72 | { |
73 | 73 | public: |
74 | 74 | PlaylistTrack(UIListGenericTree *parent, const QString &title); |
| 75 | virtual ~PlaylistTrack(); |
75 | 76 | |
76 | 77 | void setOwner(Track *owner); |
77 | 78 | void userSelectedMe(); |