Resolve TODO about possible use after free bug.

This commit is contained in:
Alex Wilson
2012-04-01 11:54:25 +12:00
parent 3c7caf81db
commit 91b523054f
3 changed files with 19 additions and 5 deletions
+4 -5
View File
@@ -185,11 +185,10 @@ AppGroupView::AddInfo(NotificationView* view)
for (int32 i = 0; i < children; i++) { for (int32 i = 0; i < children; i++) {
if (id == fInfo[i]->MessageID()) { if (id == fInfo[i]->MessageID()) {
// TODO: because NotificationWindow also tracks these NotificationView* oldView = fInfo[i];
// views, we may be heading towards a use-after-free with fParent->NotificationViewSwapped(oldView, view);
// this code. GetLayout()->RemoveView(oldView);
GetLayout()->RemoveView(fInfo[i]); delete oldView;
delete fInfo[i];
fInfo[i] = view; fInfo[i] = view;
found = true; found = true;
@@ -324,6 +324,17 @@ NotificationWindow::_ShowHide()
} }
void
NotificationWindow::NotificationViewSwapped(NotificationView* stale,
NotificationView* fresh)
{
views_t::iterator it = find(fViews.begin(), fViews.end(), stale);
if (it != fViews.end())
*it = fresh;
}
void void
NotificationWindow::SetPosition() NotificationWindow::SetPosition()
{ {
@@ -57,6 +57,10 @@ public:
private: private:
friend class AppGroupView; friend class AppGroupView;
void NotificationViewSwapped(
NotificationView* stale,
NotificationView* fresh);
void SetPosition(); void SetPosition();
void _LoadSettings(bool startMonitor = false); void _LoadSettings(bool startMonitor = false);
void _LoadAppFilters(bool startMonitor = false); void _LoadAppFilters(bool startMonitor = false);