mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
Fix corner cases and duplicate events, comments
This commit is contained in:
parent
21ec694822
commit
747518173d
@ -266,6 +266,9 @@ void Context::onAddDocument(Doc* doc)
|
||||
if (m_activeSiteHandler)
|
||||
m_activeSiteHandler->addDoc(doc);
|
||||
|
||||
// Checking for an active site handler of UI not available avoids a consistency issue
|
||||
// when opening a sprite from the first time, from the home screen, which would notify of an empty
|
||||
// active site twice.
|
||||
if (m_activeSiteHandler || !isUIAvailable())
|
||||
notifyActiveSiteChanged();
|
||||
}
|
||||
|
@ -269,9 +269,12 @@ void onAfterCommand(CommandExecutionEvent& ev)
|
||||
// ContextObserver impl
|
||||
void onActiveSiteChange(const Site& site) override
|
||||
{
|
||||
if (m_lastActiveSite.has_value() && *m_lastActiveSite == site)
|
||||
return; // Avoid multiple events that can happen when closing since we're changing views at the
|
||||
// same time we're removing documents
|
||||
if (m_lastActiveSite.has_value() && *m_lastActiveSite == site) {
|
||||
// Avoid multiple events that can happen when closing since
|
||||
// we're changing views at the same time we're removing
|
||||
// documents
|
||||
return;
|
||||
}
|
||||
|
||||
const bool fromUndo = (site.document() && site.document()->isUndoing());
|
||||
call(SiteChange,
|
||||
|
@ -117,16 +117,8 @@ public:
|
||||
|
||||
inline bool operator==(const Site& other) const
|
||||
{
|
||||
if (document() != other.document())
|
||||
return false;
|
||||
|
||||
if (frame() != other.frame())
|
||||
return false;
|
||||
|
||||
if (cel() != other.cel())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return (document() == other.document() && sprite() == other.sprite() &&
|
||||
layer() == other.layer() && frame() == other.frame() && cel() == other.cel());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -413,8 +413,7 @@ void MainWindow::onResize(ui::ResizeEvent& ev)
|
||||
|
||||
void MainWindow::onBeforeViewChange()
|
||||
{
|
||||
if (!getDocView())
|
||||
UIContext::instance()->notifyBeforeActiveSiteChanged();
|
||||
UIContext::instance()->notifyBeforeActiveSiteChanged();
|
||||
}
|
||||
|
||||
// When the active view is changed from methods like
|
||||
|
@ -99,7 +99,9 @@ void Workspace::setActiveView(WorkspaceView* view)
|
||||
if (!m_activePanel)
|
||||
return;
|
||||
|
||||
BeforeViewChanged();
|
||||
// Avoid duplicating the BeforeViewChanged event when we open for the first time
|
||||
if (m_activePanel->activeView() != view)
|
||||
BeforeViewChanged();
|
||||
|
||||
m_activePanel->setActiveView(view);
|
||||
|
||||
|
@ -313,7 +313,6 @@ void UIContext::onAddDocument(Doc* doc)
|
||||
// Add a tab with the new view for the document
|
||||
App::instance()->workspace()->addView(view);
|
||||
|
||||
setActiveView(view);
|
||||
view->editor()->setDefaultScroll();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user