Use std::unique_ptr inside NavigationView.

This commit is contained in:
Jared Boone 2015-12-14 11:11:49 -08:00
parent 18c4672ba2
commit 969d9bd070
2 changed files with 9 additions and 9 deletions

View file

@ -48,12 +48,15 @@ NavigationView::NavigationView()
{
}
void NavigationView::push_view(View* new_view) {
View* NavigationView::push_view(std::unique_ptr<View> new_view) {
free_view();
view_stack.push_back(new_view);
const auto p = new_view.get();
view_stack.emplace_back(std::move(new_view));
update_view();
return p;
}
void NavigationView::pop() {
@ -61,7 +64,6 @@ void NavigationView::pop() {
if( view_stack.size() > 1 ) {
free_view();
delete view_stack.back();
view_stack.pop_back();
update_view();
@ -73,7 +75,7 @@ void NavigationView::free_view() {
}
void NavigationView::update_view() {
const auto new_view = view_stack.back();
const auto new_view = view_stack.back().get();
add_child(new_view);
new_view->set_parent_rect({ {0, 0}, size() });
focus();