[Libreoffice-commits] core.git: 2 commits - svx/source vcl/source
Michael Stahl
mstahl at redhat.com
Tue Oct 14 06:12:42 PDT 2014
svx/source/svdraw/svdomedia.cxx | 27 +++++++++++++++++++--------
vcl/source/gdi/impfont.cxx | 2 +-
2 files changed, 20 insertions(+), 9 deletions(-)
New commits:
commit 782caa59cc0f72ef377b1d2c99b552b1be201f44
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Oct 14 15:04:26 2014 +0200
svx: fix another temp file leak, from SdrMediaObj's glTF models
These need a whole directory, apparently a model may have multiple
files.
Change-Id: I092c1764ddb1ed30947034f299fbb6882658d21b
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index da5860b..4655ec9 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -41,6 +41,7 @@
// For handling of glTF models
#include <unotools/tempfile.hxx>
+#include <unotools/localfilehelper.hxx>
#include <tools/urlobj.hxx>
using namespace ::com::sun::star;
@@ -54,10 +55,17 @@ using namespace ::com::sun::star;
struct MediaTempFile
{
OUString const m_TempFileURL;
- MediaTempFile(OUString const& rURL) : m_TempFileURL(rURL) {}
+ OUString const m_TempDirURL; // yet another hack, for the glTF models
+ MediaTempFile(OUString const& rURL, OUString const& rDirURL)
+ : m_TempFileURL(rURL), m_TempDirURL(rDirURL)
+ {}
~MediaTempFile()
{
::osl::File::remove(m_TempFileURL);
+ if (!m_TempDirURL.isEmpty())
+ {
+ ::utl::removeTree(m_TempDirURL);
+ }
}
};
@@ -270,10 +278,11 @@ uno::Reference<io::XInputStream> SdrMediaObj::GetInputStream()
static bool lcl_HandleJsonPackageURL(
const OUString& rURL,
SdrModel* const pModel,
- OUString& o_rTempFileURL)
+ OUString& o_rTempFileURL,
+ OUString& o_rTempDirURL)
{
// Create a temporary folder which will contain all files of glTF model
- const OUString sTempFolder = ::utl::TempFile( NULL, true ).GetURL();
+ o_rTempDirURL = ::utl::TempFile(NULL, true).GetURL();
const sal_uInt16 nPackageLength = OString("vnd.sun.star.Package:").getLength();
const OUString sUrlPath = rURL.copy(nPackageLength,rURL.lastIndexOf("/")-nPackageLength);
@@ -298,7 +307,7 @@ static bool lcl_HandleJsonPackageURL(
{
// Generate temp file path
const OUString& rFilename = aFilenames[nFileIndex];
- INetURLObject aUrlObj(sTempFolder);
+ INetURLObject aUrlObj(o_rTempDirURL);
aUrlObj.insertName(rFilename);
const OUString sFilepath = aUrlObj.GetMainURL( INetURLObject::NO_DECODE );
@@ -367,7 +376,7 @@ void SdrMediaObj::SetInputStream(uno::Reference<io::XInputStream> const& xStream
bool const bSuccess = lcl_CopyToTempFile(xStream, tempFileURL);
if (bSuccess)
{
- m_pImpl->m_pTempFile.reset(new MediaTempFile(tempFileURL));
+ m_pImpl->m_pTempFile.reset(new MediaTempFile(tempFileURL, ""));
m_pImpl->m_MediaProperties.setURL(
m_pImpl->m_LastFailedPkgURL, tempFileURL, "");
}
@@ -429,16 +438,18 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
rNewProperties.getTempURL()))
{
OUString tempFileURL;
+ OUString tempDirURL;
bool bSuccess;
#if HAVE_FEATURE_GLTF
if( url.endsWith(".json") )
- bSuccess = lcl_HandleJsonPackageURL(url, GetModel(), tempFileURL);
+ bSuccess = lcl_HandleJsonPackageURL(url, GetModel(), tempFileURL, tempDirURL);
else
#endif
- bSuccess = lcl_HandlePackageURL( url, GetModel(), tempFileURL);
+ bSuccess = lcl_HandlePackageURL(url, GetModel(), tempFileURL);
if (bSuccess)
{
- m_pImpl->m_pTempFile.reset(new MediaTempFile(tempFileURL));
+ m_pImpl->m_pTempFile.reset(
+ new MediaTempFile(tempFileURL, tempDirURL));
m_pImpl->m_MediaProperties.setURL(url, tempFileURL, "");
}
else // this case is for Clone via operator=
commit 616445cde0b594de1e6308944d3743cc64cd2a82
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Oct 14 14:44:33 2014 +0200
vcl: warning C4717: GetCharCount() recursive on all control paths
Change-Id: Id86dcd2c701510ce15cc2cf71e35c1d908ec6049
diff --git a/vcl/source/gdi/impfont.cxx b/vcl/source/gdi/impfont.cxx
index 7f80a38..354edc1 100644
--- a/vcl/source/gdi/impfont.cxx
+++ b/vcl/source/gdi/impfont.cxx
@@ -416,7 +416,7 @@ bool FontCharMap::IsDefaultMap() const
int FontCharMap::GetCharCount() const
{
- return GetCharCount();
+ return mpImplFontCharMap->mnCharCount;
}
int FontCharMap::CountCharsInRange( sal_UCS4 cMin, sal_UCS4 cMax ) const
More information about the Libreoffice-commits
mailing list