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++) {
if (id == fInfo[i]->MessageID()) {
// TODO: because NotificationWindow also tracks these
// views, we may be heading towards a use-after-free with
// this code.
GetLayout()->RemoveView(fInfo[i]);
delete fInfo[i];
NotificationView* oldView = fInfo[i];
fParent->NotificationViewSwapped(oldView, view);
GetLayout()->RemoveView(oldView);
delete oldView;
fInfo[i] = view;
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
NotificationWindow::SetPosition()
{
@@ -57,6 +57,10 @@ public:
private:
friend class AppGroupView;
void NotificationViewSwapped(
NotificationView* stale,
NotificationView* fresh);
void SetPosition();
void _LoadSettings(bool startMonitor = false);
void _LoadAppFilters(bool startMonitor = false);