Skip to content
Permalink
Browse files

Merge pull request #372 from lassoan/371-ensure-base-style-infinite-r…

…ecursion-crash

Prevent reentrant calling of ctkProxyStyle::ensureBaseStyle()
  • Loading branch information
jcfr committed Oct 1, 2013
2 parents 90000c3 + a8ebaef commit f64b68acd717dab060db41e8bee3f0f30df1a58f
Showing with 9 additions and 0 deletions.
  1. +9 −0 Libs/Widgets/ctkProxyStyle.cpp
@@ -38,11 +38,13 @@ class ctkProxyStylePrivate
private:
ctkProxyStylePrivate(ctkProxyStyle& object);
mutable QPointer <QStyle> baseStyle;
mutable bool ensureBaseStyleInProgress;
};

// ----------------------------------------------------------------------------
ctkProxyStylePrivate::ctkProxyStylePrivate(ctkProxyStyle& object)
: q_ptr(&object)
, ensureBaseStyleInProgress(false)
{
}

@@ -102,6 +104,12 @@ ctkProxyStyle::~ctkProxyStyle()
void ctkProxyStyle::ensureBaseStyle() const
{
Q_D(const ctkProxyStyle);
if (d->ensureBaseStyleInProgress)
{
// avoid infinite loop
return;
}
d->ensureBaseStyleInProgress = true;
d->baseStyle = this->baseStyle();
// Set the proxy to the entire hierarchy.
QProxyStyle* proxyStyle = const_cast<QProxyStyle*>(qobject_cast<const QProxyStyle*>(
@@ -115,6 +123,7 @@ void ctkProxyStyle::ensureBaseStyle() const
baseStyle = proxy ? proxy->baseStyle() : 0;
}
d->setBaseStyle(proxyStyle, proxyBaseStyle);
d->ensureBaseStyleInProgress = false;
}

// ----------------------------------------------------------------------------

0 comments on commit f64b68a

Please sign in to comment.
You can’t perform that action at this time.