summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/bitmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/bitmap.cpp')
-rw-r--r--src/lib/util/bitmap.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/lib/util/bitmap.cpp b/src/lib/util/bitmap.cpp
index 5f4d2adfacb..76eb764e129 100644
--- a/src/lib/util/bitmap.cpp
+++ b/src/lib/util/bitmap.cpp
@@ -289,8 +289,12 @@ void bitmap_t::resize(int width, int height, int xslop, int yslop)
{
// if we need more memory, just realloc
palette_t *const palette = m_palette;
+ if (palette)
+ palette->ref();
allocate(width, height, xslop, yslop);
set_palette(palette);
+ if (palette)
+ palette->deref();
}
else
{
@@ -400,19 +404,15 @@ void bitmap_t::wrap(bitmap_t &source, const rectangle &subrect)
void bitmap_t::set_palette(palette_t *palette)
{
- // first dereference any existing palette
- if (m_palette != nullptr)
- {
+ // first reference the new palette
+ if (palette)
+ palette->ref();
+
+ // then dereference any existing palette
+ if (m_palette)
m_palette->deref();
- m_palette = nullptr;
- }
- // then reference any new palette
- if (palette != nullptr)
- {
- palette->ref();
- m_palette = palette;
- }
+ m_palette = palette;
}
/**