Kaydet (Commit) 97ecb2af authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Thorsten Behrens

tdf#119856 vcl: convert Qt5FilePicker and Qt5Menu to RunInMainThread

... and also convert KDE5FilePicker. And Qt5Frame.

The UNO methods in Qt5FilePicker/KDE5FilePicker have to ensure that the
thread actually owns SolarMutex, because if RunInMainThread() is
called without that it will deadlock.

Change-Id: Ie4d2f494ac81c799ec7c9a3acb3a9b0f77bb6361
Reviewed-on: https://gerrit.libreoffice.org/68357
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit 7e251025)
Reviewed-on: https://gerrit.libreoffice.org/72660Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 5be0bd7c
...@@ -158,121 +158,6 @@ protected: ...@@ -158,121 +158,6 @@ protected:
virtual void addCustomControl(sal_Int16 controlId); virtual void addCustomControl(sal_Int16 controlId);
void setCustomControlWidgetLayout(QGridLayout* pLayout) { m_pLayout = pLayout; } void setCustomControlWidgetLayout(QGridLayout* pLayout) { m_pLayout = pLayout; }
private Q_SLOTS:
// XExecutableDialog functions
/// @throws css::uno::RuntimeException
void setTitleSlot(const OUString& rTitle) { return setTitle(rTitle); }
/// @throws css::uno::RuntimeException
sal_Int16 executeSlot() { return execute(); }
// XFilePicker functions
/// @throws css::uno::RuntimeException
void setMultiSelectionModeSlot(bool bMode) { return setMultiSelectionMode(bMode); }
/// @throws css::uno::RuntimeException
void setDefaultNameSlot(const OUString& rName) { return setDefaultName(rName); }
/// @throws css::uno::RuntimeException
void setDisplayDirectorySlot(const OUString& rDirectory)
{
return setDisplayDirectory(rDirectory);
}
/// @throws css::uno::RuntimeException
OUString getDisplayDirectorySlot() { return getDisplayDirectory(); }
/// @throws css::uno::RuntimeException
css::uno::Sequence<OUString> getFilesSlot() { return getFiles(); }
// XFilterManager functions
/// @throws css::lang::IllegalArgumentException
/// @throws css::uno::RuntimeException
void appendFilterSlot(const OUString& rTitle, const OUString& rFilter)
{
return appendFilter(rTitle, rFilter);
}
/// @throws css::lang::IllegalArgumentException
/// @throws css::uno::RuntimeException
void setCurrentFilterSlot(const OUString& rTitle) { return setCurrentFilter(rTitle); }
/// @throws css::uno::RuntimeException
OUString getCurrentFilterSlot() { return getCurrentFilter(); }
// XFilterGroupManager functions
/// @throws css::lang::IllegalArgumentException
/// @throws css::uno::RuntimeException
void appendFilterGroupSlot(const OUString& rGroupTitle,
const css::uno::Sequence<css::beans::StringPair>& rFilters)
{
return appendFilterGroup(rGroupTitle, rFilters);
}
// XFilePickerControlAccess functions
/// @throws css::uno::RuntimeException
void setValueSlot(sal_Int16 nControlId, sal_Int16 nControlAction, const css::uno::Any& rValue)
{
return setValue(nControlId, nControlAction, rValue);
}
/// @throws css::uno::RuntimeException
css::uno::Any getValueSlot(sal_Int16 nControlId, sal_Int16 nControlAction)
{
return getValue(nControlId, nControlAction);
}
/// @throws css::uno::RuntimeException
void enableControlSlot(sal_Int16 nControlId, bool bEnable)
{
return enableControl(nControlId, bEnable);
}
/// @throws css::uno::RuntimeException
void setLabelSlot(sal_Int16 nControlId, const OUString& rLabel)
{
return setLabel(nControlId, rLabel);
}
/// @throws css::uno::RuntimeException
OUString getLabelSlot(sal_Int16 nControlId) { return getLabel(nControlId); }
// XFilePicker2 functions
/// @throws css::uno::RuntimeException
css::uno::Sequence<OUString> getSelectedFilesSlot() { return getSelectedFiles(); }
// XInitialization
/// @throws css::uno::Exception
/// @throws css::uno::RuntimeException
void initializeSlot(const css::uno::Sequence<css::uno::Any>& rArguments)
{
return initialize(rArguments);
}
Q_SIGNALS:
// XExecutableDialog functions
void setTitleSignal(const OUString& rTitle);
sal_Int16 executeSignal();
// XFilePicker functions
void setMultiSelectionModeSignal(bool bMode);
void setDefaultNameSignal(const OUString& rName);
void setDisplayDirectorySignal(const OUString& rDirectory);
OUString getDisplayDirectorySignal();
css::uno::Sequence<OUString> getFilesSignal();
// XFilterManager functions
void appendFilterSignal(const OUString& rTitle, const OUString& rFilter);
void setCurrentFilterSignal(const OUString& rTitle);
OUString getCurrentFilterSignal();
// XFilterGroupManager functions
void appendFilterGroupSignal(const OUString& rGroupTitle,
const css::uno::Sequence<css::beans::StringPair>& rFilters);
// XFilePickerControlAccess functions
void setValueSignal(sal_Int16 nControlId, sal_Int16 nControlAction,
const css::uno::Any& rValue);
css::uno::Any getValueSignal(sal_Int16 nControlId, sal_Int16 nControlAction);
void enableControlSignal(sal_Int16 nControlId, bool bEnable);
void setLabelSignal(sal_Int16 nControlId, const OUString& rLabel);
OUString getLabelSignal(sal_Int16 nControlId);
// XFilePicker2 functions
css::uno::Sequence<OUString> getSelectedFilesSignal();
// XInitialization
void initializeSignal(const css::uno::Sequence<css::uno::Any>& rArguments);
private: private:
Qt5FilePicker(const Qt5FilePicker&) = delete; Qt5FilePicker(const Qt5FilePicker&) = delete;
Qt5FilePicker& operator=(const Qt5FilePicker&) = delete; Qt5FilePicker& operator=(const Qt5FilePicker&) = delete;
......
...@@ -107,11 +107,10 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame ...@@ -107,11 +107,10 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame
void TriggerPaintEvent(); void TriggerPaintEvent();
void TriggerPaintEvent(QRect aRect); void TriggerPaintEvent(QRect aRect);
private Q_SLOTS: private:
void setVisible(bool); void setVisible(bool);
Q_SIGNALS: Q_SIGNALS:
void setVisibleSignal(bool);
void tooltipRequest(const OUString& rTooltip); void tooltipRequest(const OUString& rTooltip);
public: public:
......
This diff is collapsed.
...@@ -128,7 +128,6 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) ...@@ -128,7 +128,6 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
else else
m_pQWidget = new Qt5Widget(*this, aWinFlags); m_pQWidget = new Qt5Widget(*this, aWinFlags);
connect(this, SIGNAL(setVisibleSignal(bool)), SLOT(setVisible(bool)));
connect(this, &Qt5Frame::tooltipRequest, static_cast<Qt5Widget*>(m_pQWidget), connect(this, &Qt5Frame::tooltipRequest, static_cast<Qt5Widget*>(m_pQWidget),
&Qt5Widget::showTooltip); &Qt5Widget::showTooltip);
...@@ -358,7 +357,9 @@ void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/) ...@@ -358,7 +357,9 @@ void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/)
if (m_bDefaultSize) if (m_bDefaultSize)
SetDefaultSize(); SetDefaultSize();
Q_EMIT setVisibleSignal(bVisible); auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
assert(pSalInst);
pSalInst->RunInMainThread([this, bVisible]() { setVisible(bVisible); });
} }
void Qt5Frame::SetMinClientSize(long nWidth, long nHeight) void Qt5Frame::SetMinClientSize(long nWidth, long nHeight)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <Qt5Menu.hxx> #include <Qt5Menu.hxx>
#include <Qt5Menu.moc> #include <Qt5Menu.moc>
#include <Qt5Instance.hxx>
#include <Qt5Frame.hxx> #include <Qt5Frame.hxx>
#include <Qt5Instance.hxx> #include <Qt5Instance.hxx>
...@@ -393,10 +394,12 @@ void Qt5Menu::SetSubMenu(SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned ...@@ -393,10 +394,12 @@ void Qt5Menu::SetSubMenu(SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned
void Qt5Menu::SetFrame(const SalFrame* pFrame) void Qt5Menu::SetFrame(const SalFrame* pFrame)
{ {
if (qApp->thread() != QThread::currentThread()) auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
assert(pSalInst);
if (!pSalInst->IsMainThread())
{ {
SolarMutexReleaser aReleaser; pSalInst->RunInMainThread([this, pFrame]() { SetFrame(pFrame); });
return Q_EMIT setFrameSignal(pFrame); return;
} }
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
......
...@@ -92,9 +92,6 @@ private: ...@@ -92,9 +92,6 @@ private:
protected: protected:
bool eventFilter(QObject* watched, QEvent* event) override; bool eventFilter(QObject* watched, QEvent* event) override;
Q_SIGNALS:
sal_Int16 executeSignal();
}; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <unx/geninst.h> #include <unx/geninst.h>
#include <qt5/Qt5Tools.hxx> #include <qt5/Qt5Tools.hxx>
#include <qt5/Qt5Instance.hxx>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QThread> #include <QtCore/QThread>
...@@ -106,19 +107,20 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode) ...@@ -106,19 +107,20 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
QStringLiteral("smb"), QStringLiteral("smb"),
}); });
connect(this, &KDE5FilePicker::executeSignal, this, &KDE5FilePicker::execute,
Qt::BlockingQueuedConnection);
// used to set the custom controls // used to set the custom controls
qApp->installEventFilter(this); qApp->installEventFilter(this);
} }
sal_Int16 SAL_CALL KDE5FilePicker::execute() sal_Int16 SAL_CALL KDE5FilePicker::execute()
{ {
if (qApp->thread() != QThread::currentThread()) SolarMutexGuard g;
auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
assert(pSalInst);
if (!pSalInst->IsMainThread())
{ {
//SolarMutexReleaser aReleaser; sal_Int16 ret;
return Q_EMIT executeSignal(); pSalInst->RunInMainThread([&ret, this] { ret = execute(); });
return ret;
} }
if (!m_aNamedFilterList.isEmpty()) if (!m_aNamedFilterList.isEmpty())
...@@ -144,10 +146,16 @@ void SAL_CALL KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAc ...@@ -144,10 +146,16 @@ void SAL_CALL KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAc
uno::Any SAL_CALL KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nControlAction) uno::Any SAL_CALL KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nControlAction)
{ {
if (qApp->thread() != QThread::currentThread()) SolarMutexGuard g;
auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
assert(pSalInst);
if (!pSalInst->IsMainThread())
{ {
SolarMutexReleaser aReleaser; uno::Any ret;
return Q_EMIT getValueSignal(controlId, nControlAction); pSalInst->RunInMainThread([&ret, this, controlId, nControlAction]() {
ret = getValue(controlId, nControlAction);
});
return ret;
} }
if (CHECKBOX_AUTOEXTENSION == controlId) if (CHECKBOX_AUTOEXTENSION == controlId)
......
...@@ -63,6 +63,7 @@ KDE5SalInstance::createFilePicker(const uno::Reference<uno::XComponentContext>& ...@@ -63,6 +63,7 @@ KDE5SalInstance::createFilePicker(const uno::Reference<uno::XComponentContext>&
{ {
if (!IsMainThread()) if (!IsMainThread())
{ {
SolarMutexGuard g;
uno::Reference<ui::dialogs::XFilePicker2> xRet; uno::Reference<ui::dialogs::XFilePicker2> xRet;
RunInMainThread( RunInMainThread(
std::function([&xRet, this, xMSF]() { xRet = this->createFilePicker(xMSF); })); std::function([&xRet, this, xMSF]() { xRet = this->createFilePicker(xMSF); }));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment