Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: ui/app_list/views/apps_grid_view.cc

Issue 302803002: Refactor app list so AppsGridView owns the PaginationModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests and bugs. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/app_list/views/apps_grid_view.cc
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index 52034d8c024b4de49027bdab98b83935e43982c5..5c6193ca52a4871da517621b6d23c66305bf0d49 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -335,14 +335,13 @@ class SynchronousDrag : public ui::DragSourceWin {
};
#endif // defined(OS_WIN)
-AppsGridView::AppsGridView(AppsGridViewDelegate* delegate,
- PaginationModel* pagination_model)
+AppsGridView::AppsGridView(AppsGridViewDelegate* delegate)
: model_(NULL),
item_list_(NULL),
delegate_(delegate),
folder_delegate_(NULL),
- pagination_model_(pagination_model),
- page_switcher_view_(new PageSwitcher(pagination_model)),
+ pagination_model_(new PaginationModel),
+ page_switcher_view_(new PageSwitcher(pagination_model_.get())),
cols_(0),
rows_per_page_(0),
selected_view_(NULL),
@@ -384,6 +383,12 @@ AppsGridView::~AppsGridView() {
if (item_list_)
item_list_->RemoveObserver(this);
+
+ // Since |pagination_model_| will be destroyed before the views,
+ // |page_switcher_view_| must stop observing. (We cannot simply call
+ // RemoveAllChildViews, since that will trigger a ViewHierarchyChanged which
+ // should not be called during destruction.)
xiyuan 2014/05/30 15:47:47 RemoveAllChildViews could be called from a view's
tapted 2014/06/02 04:02:21 (#guessing) Perhaps because PageSwitcher is a "sib
Matt Giuca 2014/06/02 07:11:23 I can't call RemoveAllChildViews from this view's
tapted 2014/06/02 08:36:49 yep - that ;) True, it's a lazy/not-ideal way to
xiyuan 2014/06/02 17:02:08 CHECK_EQ is added to catch a crash where view_mode
Matt Giuca 2014/06/03 01:52:36 Ah OK, I didn't realise it was as simple as cleari
+ page_switcher_view_->ReleasePaginationModel();
}
void AppsGridView::SetLayout(int icon_size, int cols, int rows_per_page) {

Powered by Google App Engine
This is Rietveld 408576698