Fix deadlock when using textoverlay from main thread

This commit is contained in:
Bradley Austin Davis 2015-07-22 07:23:12 -04:00
parent 6dbe6bc375
commit ae539afafb
2 changed files with 9 additions and 8 deletions

View file

@ -4474,7 +4474,11 @@ void Application::friendsWindowClosed() {
}
void Application::postLambdaEvent(std::function<void()> f) {
QCoreApplication::postEvent(this, new LambdaEvent(f));
if (this->thread() == QThread::currentThread()) {
f();
} else {
QCoreApplication::postEvent(this, new LambdaEvent(f));
}
}
void Application::initPlugins() {

View file

@ -85,7 +85,6 @@ TextOverlay::TextOverlay() :
_topMargin(DEFAULT_MARGIN),
_fontSize(DEFAULT_FONTSIZE)
{
qApp->postLambdaEvent([=] {
static std::once_flag once;
std::call_once(once, [] {
@ -117,7 +116,7 @@ TextOverlay::TextOverlay(const TextOverlay* textOverlay) :
});
});
while (!_qmlElement) {
QThread::sleep(1);
QThread::msleep(1);
}
}
@ -147,14 +146,12 @@ xColor TextOverlay::getBackgroundColor() {
}
void TextOverlay::render(RenderArgs* args) {
if (!_qmlElement) {
return;
}
if (_visible != _qmlElement->isVisible()) {
_qmlElement->setVisible(_visible);
}
float pulseLevel = updatePulse();
static float _oldPulseLevel = 0.0f;
if (pulseLevel != _oldPulseLevel) {
}
}