From b7d1371910dad02c05bfd9ecd65a73de97871b9c Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Tue, 18 Sep 2018 11:25:05 +0200 Subject: Qt5 minimal initial fix for Java UNO This is just a minimal fix for Qt errors from JunitTest_svx_unoapi, which was manipulating Qt5Timer and other timers, resulting in a spew of timer error messages like: QObject::killTimer: Timers cannot be stopped from another thread QObject::startTimer: Timers cannot be started from another thread QBasicTimer::start: QBasicTimer can only be used with threads started with QThread Eventually all the QWidget manipulation in the Qt5Frame must be redirected to the main thread, just like Qt5FilePicker already does. Change-Id: I66054e6c90f99d27bd5818dcaa5876c515867f77 Reviewed-on: https://gerrit.libreoffice.org/60672 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski --- vcl/qt5/Qt5Frame.cxx | 15 +++++++++++---- vcl/qt5/Qt5Timer.cxx | 23 +++++++++-------------- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'vcl/qt5') diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index 3365ed4af3b8..b42ec5e08a0c 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -108,6 +109,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) } else m_pQWidget = new Qt5Widget(*this, aWinFlags); + connect(this, SIGNAL(setVisibleSignal(bool)), SLOT(setVisible(bool))); if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG)) { @@ -301,6 +303,14 @@ void Qt5Frame::DrawMenuBar() { /* not needed */} void Qt5Frame::SetExtendedFrameStyle(SalExtStyle /*nExtStyle*/) { /* not needed */} +void Qt5Frame::setVisible(bool bVisible) +{ + if (m_pTopLevel) + m_pTopLevel->setVisible(bVisible); + else + m_pQWidget->setVisible(bVisible); +} + void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/) { assert(m_pQWidget); @@ -308,10 +318,7 @@ void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/) if (m_bDefaultSize) SetDefaultSize(); - if (m_pTopLevel) - m_pTopLevel->setVisible(bVisible); - else - m_pQWidget->setVisible(bVisible); + Q_EMIT setVisibleSignal(bVisible); } void Qt5Frame::SetMinClientSize(long nWidth, long nHeight) diff --git a/vcl/qt5/Qt5Timer.cxx b/vcl/qt5/Qt5Timer.cxx index 6a9faf829342..7fcb7e17dcda 100644 --- a/vcl/qt5/Qt5Timer.cxx +++ b/vcl/qt5/Qt5Timer.cxx @@ -24,14 +24,14 @@ #include #include +#include Qt5Timer::Qt5Timer() { m_aTimer.setSingleShot(true); - // run the timer itself in the main / creator thread - connect(&m_aTimer, SIGNAL(timeout()), this, SLOT(timeoutActivated()), Qt::QueuedConnection); - // QTimer::start() can be called only in its creator thread - connect(this, SIGNAL(startTimerSignal()), this, SLOT(startTimer()), Qt::QueuedConnection); + connect(&m_aTimer, SIGNAL(timeout()), this, SLOT(timeoutActivated())); + connect(this, SIGNAL(startTimerSignal(int)), this, SLOT(startTimer(int))); + connect(this, SIGNAL(stopTimerSignal()), this, SLOT(stopTimer())); } void Qt5Timer::timeoutActivated() @@ -40,17 +40,12 @@ void Qt5Timer::timeoutActivated() CallCallback(); } -void Qt5Timer::startTimer() { m_aTimer.start(); } +void Qt5Timer::startTimer(int nMS) { m_aTimer.start(nMS); } -void Qt5Timer::Start(sal_uIntPtr nMS) -{ - m_aTimer.setInterval(nMS); - if (qApp->thread() == QThread::currentThread()) - startTimer(); - else - Q_EMIT startTimerSignal(); -} +void Qt5Timer::Start(sal_uIntPtr nMS) { Q_EMIT startTimerSignal(nMS); } + +void Qt5Timer::stopTimer() { m_aTimer.stop(); } -void Qt5Timer::Stop() { m_aTimer.stop(); } +void Qt5Timer::Stop() { Q_EMIT stopTimerSignal(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit