[Libreoffice-commits] core.git: 2 commits - include/tools tools/source vcl/unx
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 11 10:17:48 UTC 2021
include/tools/zcodec.hxx | 5 +++--
tools/source/zcodec/zcodec.cxx | 34 +++++++++++++++++-----------------
vcl/unx/gtk3/gtkframe.cxx | 1 +
3 files changed, 21 insertions(+), 19 deletions(-)
New commits:
commit 57ed14b5c52c6a3504a7af8359dec436fcdf54f2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue May 11 09:01:56 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue May 11 12:17:11 2021 +0200
fix leak in ZCodec
Change-Id: Ifec23a2e83a4327d954a9978ee3885a1f0889d6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115377
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index 17e44a500a41..c9c71bf752b1 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -22,6 +22,7 @@
#include <tools/toolsdllapi.h>
#include <tools/long.hxx>
+#include <memory>
#define ZCODEC_NO_COMPRESSION 0
#define ZCODEC_DEFAULT_COMPRESSION 6
@@ -40,11 +41,11 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ZCodec
State meState;
bool mbStatus;
bool mbFinish;
- sal_uInt8* mpInBuf;
+ std::unique_ptr<sal_uInt8[]> mpInBuf;
size_t mnInBufSize;
size_t mnInToRead;
SvStream* mpOStm;
- sal_uInt8* mpOutBuf;
+ std::unique_ptr<sal_uInt8[]> mpOutBuf;
size_t mnOutBufSize;
int mnCompressLevel;
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index a21003afb55f..ce461d47ed0d 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -42,11 +42,9 @@ ZCodec::ZCodec( size_t nInBufSize, size_t nOutBufSize )
: meState(STATE_INIT)
, mbStatus(false)
, mbFinish(false)
- , mpInBuf(nullptr)
, mnInBufSize(nInBufSize)
, mnInToRead(0)
, mpOStm(nullptr)
- , mpOutBuf(nullptr)
, mnOutBufSize(nOutBufSize)
, mnCompressLevel(0)
, mbGzLib(false)
@@ -67,7 +65,8 @@ void ZCodec::BeginCompression( int nCompressLevel, bool gzLib )
mbFinish = false;
mpOStm = nullptr;
mnInToRead = 0xffffffff;
- mpInBuf = mpOutBuf = nullptr;
+ mpInBuf.reset();
+ mpOutBuf.reset();
auto pStream = static_cast<z_stream*>(mpsC_Stream);
pStream->total_out = pStream->total_in = 0;
mnCompressLevel = nCompressLevel;
@@ -106,8 +105,8 @@ tools::Long ZCodec::EndCompression()
retvalue = pStream->total_out;
inflateEnd( pStream );
}
- delete[] mpOutBuf;
- delete[] mpInBuf;
+ mpOutBuf.reset();
+ mpInBuf.reset();
meState = STATE_INIT;
}
return mbStatus ? retvalue : -1;
@@ -118,11 +117,11 @@ void ZCodec::Compress( SvStream& rIStm, SvStream& rOStm )
assert(meState == STATE_INIT);
mpOStm = &rOStm;
InitCompress();
- mpInBuf = new sal_uInt8[ mnInBufSize ];
+ mpInBuf.reset(new sal_uInt8[ mnInBufSize ]);
auto pStream = static_cast<z_stream*>(mpsC_Stream);
for (;;)
{
- pStream->next_in = mpInBuf;
+ pStream->next_in = mpInBuf.get();
pStream->avail_in = rIStm.ReadBytes( pStream->next_in, mnInBufSize );
if (pStream->avail_in == 0)
break;
@@ -147,15 +146,16 @@ tools::Long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
mpOStm = &rOStm;
InitDecompress(rIStm);
pStream->avail_out = mnOutBufSize;
- pStream->next_out = mpOutBuf = new sal_uInt8[ pStream->avail_out ];
+ mpOutBuf.reset(new sal_uInt8[ pStream->avail_out ]);
+ pStream->next_out = mpOutBuf.get();
do
{
if ( pStream->avail_out == 0 ) ImplWriteBack();
if ( pStream->avail_in == 0 && mnInToRead )
{
nInToRead = std::min( mnInBufSize, mnInToRead );
- pStream->next_in = mpInBuf;
- pStream->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead);
+ pStream->next_in = mpInBuf.get();
+ pStream->avail_in = rIStm.ReadBytes(mpInBuf.get(), nInToRead);
mnInToRead -= nInToRead;
}
err = mbStatus ? inflate(pStream, Z_NO_FLUSH) : Z_ERRNO;
@@ -218,8 +218,8 @@ tools::Long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize )
if ( pStream->avail_in == 0 && mnInToRead )
{
nInToRead = std::min(mnInBufSize, mnInToRead);
- pStream->next_in = mpInBuf;
- pStream->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead);
+ pStream->next_in = mpInBuf.get();
+ pStream->avail_in = rIStm.ReadBytes(mpInBuf.get(), nInToRead);
mnInToRead -= nInToRead;
}
err = mbStatus ? inflate(pStream, Z_NO_FLUSH) : Z_ERRNO;
@@ -246,8 +246,8 @@ void ZCodec::ImplWriteBack()
if ( nAvail > 0 )
{
- pStream->next_out = mpOutBuf;
- mpOStm->WriteBytes( mpOutBuf, nAvail );
+ pStream->next_out = mpOutBuf.get();
+ mpOStm->WriteBytes( mpOutBuf.get(), nAvail );
pStream->avail_out = mnOutBufSize;
}
}
@@ -260,8 +260,8 @@ void ZCodec::InitCompress()
mbStatus = deflateInit2_(
pStream, mnCompressLevel, Z_DEFLATED, MAX_WBITS, MAX_MEM_LEVEL,
Z_DEFAULT_STRATEGY, ZLIB_VERSION, sizeof (z_stream)) >= 0;
- mpOutBuf = new sal_uInt8[mnOutBufSize];
- pStream->next_out = mpOutBuf;
+ mpOutBuf.reset(new sal_uInt8[mnOutBufSize]);
+ pStream->next_out = mpOutBuf.get();
pStream->avail_out = mnOutBufSize;
}
@@ -323,7 +323,7 @@ void ZCodec::InitDecompress(SvStream & inStream)
}
if ( mbStatus )
meState = STATE_DECOMPRESS;
- mpInBuf = new sal_uInt8[ mnInBufSize ];
+ mpInBuf.reset(new sal_uInt8[ mnInBufSize ]);
}
bool ZCodec::AttemptDecompression(SvStream& rIStm, SvStream& rOStm)
commit 1965bd9645777d94d93d4caae799577af71039f8
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue May 11 09:38:12 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 11 12:16:53 2021 +0200
gtk4: gtk_widget_set_focusable needed for GtkEventControllerFocus
worth mentioning in the docs
Change-Id: I635bff1e7cf416796f78173ce719ce01f6cf1e5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115386
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 1d7ac5f965f3..b1f2becba4b2 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -1011,6 +1011,7 @@ void GtkSalFrame::InitCommon()
GtkEventController* pFocusController = gtk_event_controller_focus_new();
g_signal_connect(pFocusController, "enter", G_CALLBACK(signalFocusEnter), this);
g_signal_connect(pFocusController, "leave", G_CALLBACK(signalFocusLeave), this);
+ gtk_widget_set_focusable(pEventWidget, true);
gtk_widget_add_controller(pEventWidget, pFocusController);
#endif
#if !GTK_CHECK_VERSION(4,0,0)
More information about the Libreoffice-commits
mailing list