Fix crash closing the program when the Data Recovery tab open

This commit is contained in:
David Capello 2019-05-21 15:14:06 -03:00
parent a6041272c9
commit 0902fa7629
4 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -75,8 +76,7 @@ HomeView::~HomeView()
{
#ifdef ENABLE_DATA_RECOVERY
if (m_dataRecoveryView) {
if (m_dataRecoveryView->parent())
App::instance()->workspace()->removeView(m_dataRecoveryView);
ASSERT(!m_dataRecoveryView->parent());
delete m_dataRecoveryView;
}
#endif
@ -106,6 +106,14 @@ bool HomeView::onCloseView(Workspace* workspace, bool quitting)
return true;
}
void HomeView::onAfterRemoveView(Workspace* workspace)
{
if (m_dataRecoveryView &&
m_dataRecoveryView->parent()) {
workspace->removeView(m_dataRecoveryView);
}
}
void HomeView::onTabPopup(Workspace* workspace)
{
Menu* menu = AppMenus::instance()->getTabPopupMenu();

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
@ -50,6 +51,7 @@ namespace app {
// WorkspaceView implementation
ui::Widget* getContentWidget() override { return this; }
bool onCloseView(Workspace* workspace, bool quitting) override;
void onAfterRemoveView(Workspace* workspace) override;
void onTabPopup(Workspace* workspace) override;
void onWorkspaceViewSelected() override;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -72,12 +72,15 @@ void Workspace::addView(WorkspaceView* view, int pos)
void Workspace::removeView(WorkspaceView* view)
{
ASSERT(view);
base::remove_from_container(m_views, view);
WorkspacePanel* panel = getViewPanel(view);
ASSERT(panel);
if (panel)
panel->removeView(view);
view->onAfterRemoveView(this);
}
bool Workspace::closeView(WorkspaceView* view, bool quitting)

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
@ -38,6 +39,8 @@ namespace app {
// the user cancels the operation.
virtual bool onCloseView(Workspace* workspace, bool quitting) = 0;
virtual void onAfterRemoveView(Workspace* workspace) { }
virtual void onTabPopup(Workspace* workspace) = 0;
virtual InputChainElement* onGetInputChainElement() { return nullptr; }