summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-01-05 22:28:34 +0100
committerAndras Timar <andras.timar@collabora.com>2015-01-08 15:09:31 +0100
commitd41a564243d4960ab5b5b4eb823137e8bbb1f9cc (patch)
tree98f95e298eda678290149a2ac213f5c0ce65c71f
parentae9e08acf384954809471cae71a921fb22706974 (diff)
workaround a weird gcc optimization werror bug
gcc (GCC) 4.9.2 20141101 (Red Hat 4.9.2-1) framework/source/fwe/classes/addonsoptions.cxx: In member function ‘void framework::AddonsOptions_Impl::ReadAndAssociateImages(const rtl::OUString&, const rtl::OUString&)’: framework/source/fwe/classes/addonsoptions.cxx:267:16: error: array subscript is above array bounds [-Werror=array-bounds] struct ImageEntry ^ The combination of aScaled[2]; aImage[2]; aURL[2] in sequence apparently lead to some overoptimization and/or alignment problem, already declaring aImage[3] helped (but not aScaled[3]), but that's not what we want. Change-Id: I82e28d4887ab8072a17d0a9341d322c1cf61aedc (cherry picked from commit 549b7fad48bb9ddcba7dfa92daea6ce917853a03) Reviewed-on: https://gerrit.libreoffice.org/13764 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit e6d3d22684d6644dad04aa3f747d6fd1030966be)
-rw-r--r--framework/source/fwe/classes/addonsoptions.cxx44
1 files changed, 25 insertions, 19 deletions
diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index 5ec0e61ad29b..067dde47dc92 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -260,19 +260,24 @@ class AddonsOptions_Impl : public ConfigItem
private:
enum ImageSize
{
- IMGSIZE_SMALL,
+ IMGSIZE_SMALL = 0,
IMGSIZE_BIG
};
+ struct OneImageEntry
+ {
+ Image aScaled; ///< cached scaled image
+ Image aImage; ///< original un-scaled image
+ OUString aURL; ///< URL in case it is not loaded yet
+ };
+
struct ImageEntry
{
// if the image is set, it was embedded in some way,
// otherwise we use the associated URL to load on demand
// accessed in this order
- Image aScaled[2]; // cached scaled images
- Image aImage[2]; // original un-scaled images
- OUString aURL[2]; // URLs in case they are not loaded yet
+ OneImageEntry aSizeEntry[2];
ImageEntry() {}
void addImage(ImageSize eSize, const Image &rImage, const OUString &rURL);
};
@@ -355,8 +360,8 @@ void AddonsOptions_Impl::ImageEntry::addImage(ImageSize eSize,
const Image &rImage,
const OUString &rURL)
{
- aImage[(int)eSize] = rImage;
- aURL[(int)eSize] = rURL;
+ aSizeEntry[(int)eSize].aImage = rImage;
+ aSizeEntry[(int)eSize].aURL = rURL;
}
// constructor
@@ -589,35 +594,36 @@ Image AddonsOptions_Impl::GetImageFromURL( const OUString& aURL, bool bBig, bool
ImageManager::iterator pIter = m_aImageManager.find(aURL);
if ( pIter != m_aImageManager.end() )
{
- ImageEntry &rEntry = pIter->second;
+ OneImageEntry& rSizeEntry = pIter->second.aSizeEntry[nIdx];
+ OneImageEntry& rOtherEntry = pIter->second.aSizeEntry[nOtherIdx];
// actually read the image ...
- if (!rEntry.aImage[nIdx])
- rEntry.aImage[nIdx] = ReadImageFromURL(rEntry.aURL[nIdx]);
+ if (!rSizeEntry.aImage)
+ rSizeEntry.aImage = ReadImageFromURL(rSizeEntry.aURL);
- if (!rEntry.aImage[nIdx])
+ if (!rSizeEntry.aImage)
{ // try the other size and scale it
- aImage = ScaleImage(ReadImageFromURL(rEntry.aURL[nOtherIdx]), bBig);
- rEntry.aImage[nIdx] = aImage;
- if (!rEntry.aImage[nIdx])
+ aImage = ScaleImage(ReadImageFromURL(rOtherEntry.aURL), bBig);
+ rSizeEntry.aImage = aImage;
+ if (!rSizeEntry.aImage)
SAL_WARN("fwk", "failed to load addons image " << aURL);
}
// FIXME: bNoScale is not terribly meaningful or useful
if (!aImage && bNoScale)
- aImage = rEntry.aImage[nIdx];
+ aImage = rSizeEntry.aImage;
- if (!aImage && !!rEntry.aScaled[nIdx])
- aImage = rEntry.aScaled[nIdx];
+ if (!aImage && !!rSizeEntry.aScaled)
+ aImage = rSizeEntry.aScaled;
else // scale to the correct size for the theme / toolbox
{
- aImage = rEntry.aImage[nIdx];
+ aImage = rSizeEntry.aImage;
if (!aImage) // use and scale the other if one size is missing
- aImage = rEntry.aImage[nOtherIdx];
+ aImage = rOtherEntry.aImage;
aImage = ScaleImage(aImage, bBig);
- rEntry.aScaled[nIdx] = aImage; // cache for next time
+ rSizeEntry.aScaled = aImage; // cache for next time
}
}