Resolve TODO about possible use after free bug.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user