[Libreoffice-commits] core.git: vcl/inc vcl/opengl
Luboš Luňák (via logerrit)
logerrit at kemper.freedesktop.org
Thu Mar 28 14:43:34 UTC 2019
vcl/inc/opengl/salbmp.hxx | 1 +
vcl/opengl/salbmp.cxx | 17 +++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
New commits:
commit e299dd1dfbd67d0c662ca63df4a6eb43ea590a17
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Mar 26 13:56:11 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Mar 28 15:43:02 2019 +0100
make OpenGLSalBitmap deallocate user data properly
In OpenGLSalBitmap::AcquireBuffer(), if ReadTexture() failed, then
the data from AllocateUserData() didn't get deallocated and a next
call to OpenGLSalBitmap::AcquireBuffer() skipped the whole block
because it assumed the data was valid. Triggered while fixing tdf#116888.
Change-Id: Ibfe5c42d6b18748ca649d6b4242ef268c1b13a71
Reviewed-on: https://gerrit.libreoffice.org/69746
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index c45532434f98..bc4dc90b9605 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -93,6 +93,7 @@ private:
GLuint CreateTexture();
bool AllocateUserData();
+ void DeallocateUserData();
bool ReadTexture();
private:
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index d8a8454ca4e7..27d2e19e2734 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -258,7 +258,7 @@ void OpenGLSalBitmap::Destroy()
VCL_GL_INFO("Destroy OpenGLSalBitmap texture:" << maTexture.Id());
maTexture = OpenGLTexture();
- mpUserBuffer.reset();
+ DeallocateUserData();
}
bool OpenGLSalBitmap::AllocateUserData()
@@ -292,8 +292,7 @@ bool OpenGLSalBitmap::AllocateUserData()
if (!alloc)
{
SAL_WARN("vcl.opengl", "bad alloc " << mnBytesPerRow << "x" << mnHeight);
- mpUserBuffer.reset();
- mnBytesPerRow = 0;
+ DeallocateUserData();
}
#ifdef DBG_UTIL
else
@@ -306,6 +305,12 @@ bool OpenGLSalBitmap::AllocateUserData()
return mpUserBuffer != nullptr;
}
+void OpenGLSalBitmap::DeallocateUserData()
+{
+ mpUserBuffer.reset();
+ mnBytesPerRow = 0;
+}
+
namespace {
class ImplPixelFormat
@@ -763,7 +768,10 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode )
if( !AllocateUserData() )
return nullptr;
if( maTexture && !ReadTexture() )
+ {
+ DeallocateUserData();
return nullptr;
+ }
}
}
@@ -870,6 +878,7 @@ bool OpenGLSalBitmap::GetSystemData( BitmapSystemData& /*rData*/ )
if( !AllocateUserData() || !ReadTexture() )
{
rBitmap.ReleaseBuffer( pBuffer, false );
+ DeallocateUserData();
return false;
}
}
@@ -955,7 +964,7 @@ bool OpenGLSalBitmap::ConvertToGreyscale()
maPalette = Bitmap::GetGreyPalette(256);
// AllocateUserData will handle the rest.
- mpUserBuffer.reset();
+ DeallocateUserData();
mbDirtyTexture = false;
CHECK_GL_ERROR();
More information about the Libreoffice-commits
mailing list