diff options
author | Alessandro Portale <aportale@trolltech.com> | 2009-06-05 13:58:30 (GMT) |
---|---|---|
committer | Alessandro Portale <aportale@trolltech.com> | 2009-06-05 13:58:30 (GMT) |
commit | d0a2a16bfe73c4281277397dec0fdc8ca201f0fa (patch) | |
tree | a9d70225ba347a84a7a51e0043dc511d90b2fcac /src | |
parent | 426dc2fbefa8a901778c5fbafe6fb9ac61c4a004 (diff) | |
download | Qt-d0a2a16bfe73c4281277397dec0fdc8ca201f0fa.zip Qt-d0a2a16bfe73c4281277397dec0fdc8ca201f0fa.tar.gz Qt-d0a2a16bfe73c4281277397dec0fdc8ca201f0fa.tar.bz2 |
Prevent double deletion of m_themePalette
RevBy: Sami Merila
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/styles/qs60style.cpp | 29 | ||||
-rw-r--r-- | src/gui/styles/qs60style_p.h | 7 |
2 files changed, 20 insertions, 16 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 56b7e7c..fe24195 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -151,7 +151,7 @@ const double KTabFontMul = 0.72; QS60StylePrivate::~QS60StylePrivate() { clearCaches(); //deletes also background image - delete m_themePalette; + deleteThemePalette(); } void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, @@ -470,12 +470,10 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme void QS60StylePrivate::setThemePalette(QApplication *app) const { - if (!app) - return; - + Q_UNUSED(app) QPalette widgetPalette = QPalette(Qt::white); setThemePalette(&widgetPalette); - app->setPalette(widgetPalette); + QApplication::setPalette(widgetPalette); } void QS60StylePrivate::setThemePalette(QStyleOption *option) const @@ -490,11 +488,10 @@ QPalette* QS60StylePrivate::themePalette() void QS60StylePrivate::setBackgroundTexture(QApplication *app) const { - if (!app) - return; - QPalette applicationPalette = app->palette(); + Q_UNUSED(app) + QPalette applicationPalette = QApplication::palette(); applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); - app->setPalette(applicationPalette); + QApplication::setPalette(applicationPalette); } void QS60StylePrivate::deleteBackground() @@ -719,13 +716,18 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const QS60StylePrivate::storeThemePalette(palette); } -void QS60StylePrivate::storeThemePalette(QPalette *palette) +void QS60StylePrivate::deleteThemePalette() { - //store specified palette for latter use. if (m_themePalette) { delete m_themePalette; m_themePalette = 0; } +} + +void QS60StylePrivate::storeThemePalette(QPalette *palette) +{ + deleteThemePalette(); + //store specified palette for latter use. m_themePalette = new QPalette(*palette); } @@ -2705,9 +2707,10 @@ void QS60Style::polish(QApplication *application) void QS60Style::unpolish(QApplication *application) { + Q_UNUSED(application) Q_D(QS60Style); const QPalette newPalette = QApplication::style()->standardPalette(); - application->setPalette(newPalette); + QApplication::setPalette(newPalette); QApplicationPrivate::setSystemPalette(d->m_originalPalette); } @@ -2821,7 +2824,7 @@ bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint const QPaintDevice *target = painter->device(); if (target->devType() == QInternal::Widget) { - const QWidget *widget = static_cast<const QWidget *>(target); + const QWidget *widget = static_cast<const QWidget *>(target); const QRegion translated = rgn.translated(offset); const QVector<QRect> &rects = translated.rects(); for (int i = 0; i < rects.size(); ++i) { diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 385c6e8..54da9e8 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -410,7 +410,7 @@ public: static bool isToolBarBackground(); // calculates average color based on button skin graphics (minus borders). - QColor colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const; + QColor colorFromFrameGraphics(SkinFrameElements frame) const; //set theme palette for application void setThemePalette(QApplication *application) const; @@ -432,7 +432,7 @@ public: static const int m_numberOfLayouts; mutable QHash<QPair<QS60StyleEnums::FontCategories , int>, QFont> m_mappedFontsCache; - mutable QHash<QS60StylePrivate::SkinFrameElements, QColor> m_colorCache; + mutable QHash<SkinFrameElements, QColor> m_colorCache; // Has one entry per SkinFrameElements static const struct frameElementCenter { @@ -465,7 +465,8 @@ private: void setThemePalette(QWidget *widget) const; void setThemePalette(QPalette *palette) const; void setThemePaletteHash(QPalette *palette) const; - static void QS60StylePrivate::storeThemePalette(QPalette *palette); + static void storeThemePalette(QPalette *palette); + static void deleteThemePalette(); static QSize partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags = KDefaultSkinElementFlags); |