diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2012-11-29 08:08:43 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-29 13:51:52 +0100 |
commit | a4c7340b73fb93813b74001301b274b42990a896 (patch) | |
tree | 092541b24c118fe081088c41d23db164f0124387 | |
parent | 5e525d283d308fe462e83955996fc53d80465c1b (diff) |
Make Mac style not crash on null styleObject.
We generally expect styleObject to be set during style
draw calls but this isn't always done, especially
legacy code outside Qt (for example in Qt creator).
Create a temporary stand-in QObject. This will disable
scroll bar animations.
Change-Id: I781967fe28f68f5952b368cd56be980b9e270ecd
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index cbc58d1b5d..21b4f57525 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -4907,6 +4907,16 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient)) { QObject *styleObject = opt->styleObject; + + // Qt generally excepts styleObject to be set during draw calls, but + // this is not always done. Create a temprary object in that case to + // prevent crashing. This will disable scroll bar animations. + bool deleteStyleObject = false; + if (!styleObject) { + deleteStyleObject = true; + styleObject = new QObject; + } + int oldPos = styleObject->property("_q_stylepos").toInt(); int oldMin = styleObject->property("_q_stylemin").toInt(); int oldMax = styleObject->property("_q_stylemax").toInt(); @@ -5040,6 +5050,10 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [NSGraphicsContext restoreGraphicsState]; CGContextRestoreGState(cg); + + if (deleteStyleObject) { + delete styleObject; + } } else #endif { |