mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:37:19 +02:00
Fix deadlock when using textoverlay from main thread
This commit is contained in:
parent
6dbe6bc375
commit
ae539afafb
2 changed files with 9 additions and 8 deletions
|
@ -4474,7 +4474,11 @@ void Application::friendsWindowClosed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::postLambdaEvent(std::function<void()> f) {
|
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() {
|
void Application::initPlugins() {
|
||||||
|
|
|
@ -85,7 +85,6 @@ TextOverlay::TextOverlay() :
|
||||||
_topMargin(DEFAULT_MARGIN),
|
_topMargin(DEFAULT_MARGIN),
|
||||||
_fontSize(DEFAULT_FONTSIZE)
|
_fontSize(DEFAULT_FONTSIZE)
|
||||||
{
|
{
|
||||||
|
|
||||||
qApp->postLambdaEvent([=] {
|
qApp->postLambdaEvent([=] {
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
std::call_once(once, [] {
|
std::call_once(once, [] {
|
||||||
|
@ -117,7 +116,7 @@ TextOverlay::TextOverlay(const TextOverlay* textOverlay) :
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
while (!_qmlElement) {
|
while (!_qmlElement) {
|
||||||
QThread::sleep(1);
|
QThread::msleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,14 +146,12 @@ xColor TextOverlay::getBackgroundColor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextOverlay::render(RenderArgs* args) {
|
void TextOverlay::render(RenderArgs* args) {
|
||||||
|
if (!_qmlElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_visible != _qmlElement->isVisible()) {
|
if (_visible != _qmlElement->isVisible()) {
|
||||||
_qmlElement->setVisible(_visible);
|
_qmlElement->setVisible(_visible);
|
||||||
}
|
}
|
||||||
float pulseLevel = updatePulse();
|
|
||||||
static float _oldPulseLevel = 0.0f;
|
|
||||||
if (pulseLevel != _oldPulseLevel) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue