| Index: ui/app_list/views/page_switcher.cc
|
| diff --git a/ui/app_list/views/page_switcher.cc b/ui/app_list/views/page_switcher.cc
|
| index 84077f9a6a86a46e2b588d64ce781504a059b75b..7da2593e7ca86169e9ec7af858ccb9ec2da0c059 100644
|
| --- a/ui/app_list/views/page_switcher.cc
|
| +++ b/ui/app_list/views/page_switcher.cc
|
| @@ -128,7 +128,8 @@ PageSwitcher::PageSwitcher(PaginationModel* model)
|
| }
|
|
|
| PageSwitcher::~PageSwitcher() {
|
| - model_->RemoveObserver(this);
|
| + if (model_)
|
| + model_->RemoveObserver(this);
|
| }
|
|
|
| int PageSwitcher::GetPageForPoint(const gfx::Point& point) const {
|
| @@ -165,6 +166,13 @@ void PageSwitcher::UpdateUIForDragPoint(const gfx::Point& point) {
|
| }
|
| }
|
|
|
| +void PageSwitcher::ReleasePaginationModel() {
|
| + if (!model_)
|
| + return;
|
| + model_->RemoveObserver(this);
|
| + model_ = NULL;
|
| +}
|
| +
|
| gfx::Size PageSwitcher::GetPreferredSize() const {
|
| // Always return a size with correct height so that container resize is not
|
| // needed when more pages are added.
|
| @@ -218,6 +226,9 @@ void PageSwitcher::CalculateButtonWidthAndSpacing(int contents_width) {
|
|
|
| void PageSwitcher::ButtonPressed(views::Button* sender,
|
| const ui::Event& event) {
|
| + if (!model_)
|
| + return;
|
| +
|
| for (int i = 0; i < buttons_->child_count(); ++i) {
|
| if (sender == static_cast<views::Button*>(buttons_->child_at(i))) {
|
| model_->SelectPage(i, true /* animate */);
|
| @@ -227,6 +238,7 @@ void PageSwitcher::ButtonPressed(views::Button* sender,
|
| }
|
|
|
| void PageSwitcher::TotalPagesChanged() {
|
| + DCHECK(model_);
|
| buttons_->RemoveAllChildViews(true);
|
| for (int i = 0; i < model_->total_pages(); ++i) {
|
| PageSwitcherButton* button = new PageSwitcherButton(this);
|
| @@ -248,6 +260,7 @@ void PageSwitcher::TransitionStarted() {
|
| }
|
|
|
| void PageSwitcher::TransitionChanged() {
|
| + DCHECK(model_);
|
| const int current_page = model_->selected_page();
|
| const int target_page = model_->transition().target_page;
|
|
|
|
|