diff options
author | Harald Fernengel <harald@trolltech.com> | 2009-08-03 13:12:46 (GMT) |
---|---|---|
committer | Harald Fernengel <harald@trolltech.com> | 2009-08-03 13:12:46 (GMT) |
commit | 41a83e1ff19ad1396e6001e6b0ac003c701ba55a (patch) | |
tree | 609e40eda10418bbf925002c36552074796b96b6 /src/gui/styles/qs60style_s60.cpp | |
parent | d1f3b9df2bc5c57d414da73a7d4f9ed7b25df3db (diff) | |
download | Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.zip Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.tar.gz Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.tar.bz2 |
Squashed commit of the topic/exceptions branch.
Contains some smaller fixes and renaming of macros. Looks big,
but isn't scary at all ;)
Diffstat (limited to 'src/gui/styles/qs60style_s60.cpp')
-rw-r--r-- | src/gui/styles/qs60style_s60.cpp | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 63346da..8e9918e 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -106,10 +106,10 @@ public: static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags); private: - static QPixmap createSkinnedGraphicsL(QS60StyleEnums::SkinParts part, + static QPixmap createSkinnedGraphicsLX(QS60StyleEnums::SkinParts part, const QSize &size, QS60StylePrivate::SkinElementFlags flags); - static QPixmap createSkinnedGraphicsL(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags); - static QPixmap colorSkinnedGraphicsL(const QS60StyleEnums::SkinParts &stylepart, + static QPixmap createSkinnedGraphicsLX(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags); + static QPixmap colorSkinnedGraphicsLX(const QS60StyleEnums::SkinParts &stylepart, const QSize &size, QS60StylePrivate::SkinElementFlags flags); static void frameIdAndCenterId(QS60StylePrivate::SkinFrameElements frameElement, TAknsItemID &frameId, TAknsItemID ¢erId); static TRect innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect); @@ -336,10 +336,10 @@ QPixmap QS60StyleModeSpecifics::skinnedGraphics( QS60StylePrivate::SkinElementFlags flags) { QPixmap themedImage; - TRAPD( error, { - const QPixmap skinnedImage = createSkinnedGraphicsL(stylepart, size, flags); + TRAPD( error, QT_TRYCATCH_LEAVING({ + const QPixmap skinnedImage = createSkinnedGraphicsLX(stylepart, size, flags); themedImage = skinnedImage; - }); + })); if (error) return themedImage = QPixmap(); return themedImage; @@ -349,10 +349,10 @@ QPixmap QS60StyleModeSpecifics::skinnedGraphics( QS60StylePrivate::SkinFrameElements frame, const QSize &size, QS60StylePrivate::SkinElementFlags flags) { QPixmap themedImage; - TRAPD( error, { - const QPixmap skinnedImage = createSkinnedGraphicsL(frame, size, flags); + TRAPD( error, QT_TRYCATCH_LEAVING({ + const QPixmap skinnedImage = createSkinnedGraphicsLX(frame, size, flags); themedImage = skinnedImage; - }); + })); if (error) return themedImage = QPixmap(); return themedImage; @@ -363,7 +363,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics( const QSize &size, QS60StylePrivate::SkinElementFlags flags) { QPixmap colorGraphics; - TRAPD(error, colorGraphics = colorSkinnedGraphicsL(stylepart, size, flags)); + TRAPD(error, QT_TRYCATCH_LEAVING(colorGraphics = colorSkinnedGraphicsLX(stylepart, size, flags))); return error ? QPixmap() : colorGraphics; } @@ -521,10 +521,11 @@ void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &style } } -QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsL( +QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX( const QS60StyleEnums::SkinParts &stylepart, const QSize &size, QS60StylePrivate::SkinElementFlags flags) { + // this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts. const int stylepartIndex = (int)stylepart; const TAknsItemID skinId = m_partMap[stylepartIndex].skinID; @@ -563,6 +564,13 @@ QColor QS60StyleModeSpecifics::colorValue(const TAknsItemID &colorGroup, int col return QColor(skinnedColor.Red(),skinnedColor.Green(),skinnedColor.Blue()); } +struct QAutoFbsBitmapHeapLock +{ + QAutoFbsBitmapHeapLock(CFbsBitmap* aBmp) : mBmp(aBmp) { mBmp->LockHeap(); } + ~QAutoFbsBitmapHeapLock() { mBmp->UnlockHeap(); } + CFbsBitmap* mBmp; +}; + QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format) { Q_ASSERT(icon); @@ -589,13 +597,13 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask if (mask) { //checkAndUnCompressBitmap might set mask to NULL const TSize maskSize = icon->SizeInPixels(); const int maskBytesPerLine = CFbsBitmap::ScanLineLength(maskSize.iWidth, mask->DisplayMode()); - mask->LockHeap(); + // heap lock object required because QImage ctor might throw + QAutoFbsBitmapHeapLock maskHeapLock(mask); const uchar *const maskBytes = (uchar *)mask->DataAddress(); // Since no other bitmap should be locked, we can just "borrow" the mask data for setAlphaChannel const QImage maskImage(maskBytes, maskSize.iWidth, maskSize.iHeight, maskBytesPerLine, QImage::Format_Indexed8); if (!maskImage.isNull()) iconImage.setAlphaChannel(maskImage); - mask->UnlockHeap(); } } @@ -631,10 +639,11 @@ QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) return QPoint(globalPos.iX, globalPos.iY); } -QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( +QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( QS60StyleEnums::SkinParts part, const QSize &size, QS60StylePrivate::SkinElementFlags flags) { + // this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts. if (!size.isValid()) return QPixmap(); @@ -712,9 +721,10 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( return result; } -QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFrameElements frameElement, +QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags) { + // this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts. if (!size.isValid()) return QPixmap(); @@ -892,7 +902,10 @@ void QS60StyleModeSpecifics::checkAndUnCompressBitmap(CFbsBitmap*& aOriginalBitm void QS60StyleModeSpecifics::checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBitmap) { - if (aOriginalBitmap->IsCompressedInRAM()) { + const TSize iconSize = aOriginalBitmap->SizeInPixels(); + const int iconBytesPerLine = CFbsBitmap::ScanLineLength(iconSize.iWidth, aOriginalBitmap->DisplayMode()); + const int iconBytesCount = iconBytesPerLine * iconSize.iHeight; + if (aOriginalBitmap->IsCompressedInRAM() || aOriginalBitmap->DataSize() < iconBytesCount) { const TSize iconSize(aOriginalBitmap->SizeInPixels().iWidth, aOriginalBitmap->SizeInPixels().iHeight); CFbsBitmap* uncompressedBitmap = new (ELeave) CFbsBitmap(); @@ -941,7 +954,7 @@ QFont QS60StylePrivate::s60Font_specific( } QFont result; - TRAPD( error, { + TRAPD( error, QT_TRYCATCH_LEAVING({ const CAknLayoutFont* aknFont = AknFontAccess::CreateLayoutFontFromSpecificationL(*dev, spec); @@ -950,7 +963,7 @@ QFont QS60StylePrivate::s60Font_specific( result.setPointSize(pointSize); // Correct the font size returned by CreateLayoutFontFromSpecificationL() delete aknFont; - }); + })); if (error) result = QFont(); return result; } @@ -1178,7 +1191,9 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap User::Leave(KErrArgument); // Note! aSrcBitmap->IsCompressedInRAM() is always ETrue, since this method is called only if that applies! - ASSERT(aSrcBitmap->IsCompressedInRAM()); + // Extra note! this function is also being used when bitmaps appear to be compressed (because DataSize is too small) + // even when they pretend they are not. Assert removed. +// ASSERT(aSrcBitmap->IsCompressedInRAM()); TDisplayMode displayMode = aSrcBitmap->DisplayMode(); |