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...
Showing
with
9 additions
and
0 deletions.
-
+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