mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Fix crash using a deleted surface in Overlay::restoreOverlappedArea()
Can happen when a resize event is received and m_captured stores the surface with the old window size. This was found opening a file from the CLI on Linux/X11.
This commit is contained in:
parent
e2798bc849
commit
c58dae51fa
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2018 Igara Studio S.A.
|
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -83,7 +83,7 @@ void Overlay::moveOverlay(const gfx::Point& newPos)
|
|||||||
m_pos = newPos;
|
m_pos = newPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::captureOverlappedArea(os::Surface* screen)
|
void Overlay::captureOverlappedArea(const os::SurfaceRef& screen)
|
||||||
{
|
{
|
||||||
if (!m_surface ||
|
if (!m_surface ||
|
||||||
m_captured)
|
m_captured)
|
||||||
@ -116,7 +116,7 @@ void Overlay::restoreOverlappedArea(const gfx::Rect& restoreBounds)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
os::SurfaceLock lock(m_overlap.get());
|
os::SurfaceLock lock(m_overlap.get());
|
||||||
m_overlap->blitTo(m_captured, 0, 0, m_pos.x, m_pos.y,
|
m_overlap->blitTo(m_captured.get(), 0, 0, m_pos.x, m_pos.y,
|
||||||
m_overlap->width(), m_overlap->height());
|
m_overlap->width(), m_overlap->height());
|
||||||
|
|
||||||
Manager::getDefault()->dirtyRect(bounds());
|
Manager::getDefault()->dirtyRect(bounds());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -41,7 +41,7 @@ namespace ui {
|
|||||||
const gfx::Point& position() const { return m_pos; }
|
const gfx::Point& position() const { return m_pos; }
|
||||||
gfx::Rect bounds() const;
|
gfx::Rect bounds() const;
|
||||||
|
|
||||||
void captureOverlappedArea(os::Surface* screen);
|
void captureOverlappedArea(const os::SurfaceRef& screen);
|
||||||
void restoreOverlappedArea(const gfx::Rect& restoreBounds);
|
void restoreOverlappedArea(const gfx::Rect& restoreBounds);
|
||||||
|
|
||||||
void drawOverlay();
|
void drawOverlay();
|
||||||
@ -57,7 +57,7 @@ namespace ui {
|
|||||||
|
|
||||||
// Surface where we captured the overlapped (m_overlap)
|
// Surface where we captured the overlapped (m_overlap)
|
||||||
// region. It's nullptr if the overlay wasn't drawn yet.
|
// region. It's nullptr if the overlay wasn't drawn yet.
|
||||||
os::Surface* m_captured;
|
os::SurfaceRef m_captured;
|
||||||
|
|
||||||
gfx::Point m_pos;
|
gfx::Point m_pos;
|
||||||
ZOrder m_zorder;
|
ZOrder m_zorder;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -86,8 +86,8 @@ void OverlayManager::drawOverlays()
|
|||||||
if (!manager)
|
if (!manager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
os::Surface* displaySurface = manager->display()->surface();
|
os::SurfaceRef displaySurface(base::AddRef(manager->display()->surface()));
|
||||||
os::SurfaceLock lock(displaySurface);
|
os::SurfaceLock lock(displaySurface.get());
|
||||||
|
|
||||||
for (auto& overlay : *this)
|
for (auto& overlay : *this)
|
||||||
overlay->captureOverlappedArea(displaySurface);
|
overlay->captureOverlappedArea(displaySurface);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user