mirror of
https://github.com/aseprite/aseprite.git
synced 2024-11-20 14:21:45 +00:00
Fix crash creating/blitting a surface of empty bounds
This commit is contained in:
parent
511a34116b
commit
f470daa939
@ -26,19 +26,18 @@ SkinPart::~SkinPart()
|
||||
|
||||
void SkinPart::clear()
|
||||
{
|
||||
for (Bitmaps::iterator it = m_bitmaps.begin(), end = m_bitmaps.end();
|
||||
it != end; ++it) {
|
||||
ASSERT(*it != NULL);
|
||||
|
||||
(*it)->dispose();
|
||||
*it = NULL;
|
||||
for (auto& bitmap : m_bitmaps) {
|
||||
if (bitmap) {
|
||||
bitmap->dispose();
|
||||
bitmap = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkinPart::setBitmap(std::size_t index, she::Surface* bitmap)
|
||||
{
|
||||
if (index >= m_bitmaps.size())
|
||||
m_bitmaps.resize(index+1, NULL);
|
||||
m_bitmaps.resize(index+1, nullptr);
|
||||
|
||||
m_bitmaps[index] = bitmap;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace app {
|
||||
void setSlicesBounds(const gfx::Rect& bounds);
|
||||
|
||||
she::Surface* bitmap(std::size_t index) const {
|
||||
return (index < m_bitmaps.size() ? m_bitmaps[index]: NULL);
|
||||
return (index < m_bitmaps.size() ? m_bitmaps[index]: nullptr);
|
||||
}
|
||||
|
||||
she::Surface* bitmapNW() const { return bitmap(0); }
|
||||
|
@ -676,17 +676,20 @@ she::Surface* SkinTheme::sliceSheet(she::Surface* sur, const gfx::Rect& bounds)
|
||||
if (sur && (sur->width() != bounds.w ||
|
||||
sur->height() != bounds.h)) {
|
||||
sur->dispose();
|
||||
sur = NULL;
|
||||
sur = nullptr;
|
||||
}
|
||||
|
||||
if (!sur)
|
||||
sur = she::instance()->createRgbaSurface(bounds.w, bounds.h);
|
||||
if (!bounds.isEmpty()) {
|
||||
if (!sur)
|
||||
sur = she::instance()->createRgbaSurface(bounds.w, bounds.h);
|
||||
|
||||
{
|
||||
she::SurfaceLock lockSrc(m_sheet);
|
||||
she::SurfaceLock lockDst(sur);
|
||||
m_sheet->blitTo(sur, bounds.x, bounds.y, 0, 0, bounds.w, bounds.h);
|
||||
}
|
||||
else {
|
||||
ASSERT(!sur);
|
||||
}
|
||||
|
||||
return sur;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user