Kaydet (Commit) 549b7fad authored tarafından Eike Rathke's avatar Eike Rathke

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
üst 5c0e2024
...@@ -217,19 +217,24 @@ class AddonsOptions_Impl : public ConfigItem ...@@ -217,19 +217,24 @@ class AddonsOptions_Impl : public ConfigItem
private: private:
enum ImageSize enum ImageSize
{ {
IMGSIZE_SMALL, IMGSIZE_SMALL = 0,
IMGSIZE_BIG 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 struct ImageEntry
{ {
// if the image is set, it was embedded in some way, // if the image is set, it was embedded in some way,
// otherwise we use the associated URL to load on demand // otherwise we use the associated URL to load on demand
// accessed in this order // accessed in this order
Image aScaled[2]; // cached scaled images OneImageEntry aSizeEntry[2];
Image aImage[2]; // original un-scaled images
OUString aURL[2]; // URLs in case they are not loaded yet
ImageEntry() {} ImageEntry() {}
void addImage(ImageSize eSize, const Image &rImage, const OUString &rURL); void addImage(ImageSize eSize, const Image &rImage, const OUString &rURL);
}; };
...@@ -309,8 +314,8 @@ void AddonsOptions_Impl::ImageEntry::addImage(ImageSize eSize, ...@@ -309,8 +314,8 @@ void AddonsOptions_Impl::ImageEntry::addImage(ImageSize eSize,
const Image &rImage, const Image &rImage,
const OUString &rURL) const OUString &rURL)
{ {
aImage[(int)eSize] = rImage; aSizeEntry[(int)eSize].aImage = rImage;
aURL[(int)eSize] = rURL; aSizeEntry[(int)eSize].aURL = rURL;
} }
// constructor // constructor
...@@ -505,35 +510,36 @@ Image AddonsOptions_Impl::GetImageFromURL( const OUString& aURL, bool bBig, bool ...@@ -505,35 +510,36 @@ Image AddonsOptions_Impl::GetImageFromURL( const OUString& aURL, bool bBig, bool
ImageManager::iterator pIter = m_aImageManager.find(aURL); ImageManager::iterator pIter = m_aImageManager.find(aURL);
if ( pIter != m_aImageManager.end() ) 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 ... // actually read the image ...
if (!rEntry.aImage[nIdx]) if (!rSizeEntry.aImage)
rEntry.aImage[nIdx] = ReadImageFromURL(rEntry.aURL[nIdx]); rSizeEntry.aImage = ReadImageFromURL(rSizeEntry.aURL);
if (!rEntry.aImage[nIdx]) if (!rSizeEntry.aImage)
{ // try the other size and scale it { // try the other size and scale it
aImage = ScaleImage(ReadImageFromURL(rEntry.aURL[nOtherIdx]), bBig); aImage = ScaleImage(ReadImageFromURL(rOtherEntry.aURL), bBig);
rEntry.aImage[nIdx] = aImage; rSizeEntry.aImage = aImage;
if (!rEntry.aImage[nIdx]) if (!rSizeEntry.aImage)
SAL_WARN("fwk", "failed to load addons image " << aURL); SAL_WARN("fwk", "failed to load addons image " << aURL);
} }
// FIXME: bNoScale is not terribly meaningful or useful // FIXME: bNoScale is not terribly meaningful or useful
if (!aImage && bNoScale) if (!aImage && bNoScale)
aImage = rEntry.aImage[nIdx]; aImage = rSizeEntry.aImage;
if (!aImage && !!rEntry.aScaled[nIdx]) if (!aImage && !!rSizeEntry.aScaled)
aImage = rEntry.aScaled[nIdx]; aImage = rSizeEntry.aScaled;
else // scale to the correct size for the theme / toolbox 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 if (!aImage) // use and scale the other if one size is missing
aImage = rEntry.aImage[nOtherIdx]; aImage = rOtherEntry.aImage;
aImage = ScaleImage(aImage, bBig); aImage = ScaleImage(aImage, bBig);
rEntry.aScaled[nIdx] = aImage; // cache for next time rSizeEntry.aScaled = aImage; // cache for next time
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment