summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-06-02 21:01:33 +0000
committerMichael Weghorn <m.weghorn@posteo.de>2019-06-13 19:46:59 +0200
commitc9e626df57a3dd66613ec6b41a7d1ffb8da1843e (patch)
treefcf61b28db30056af18f61c30c1db40f6532d317
parentc98b7c9e75a951012d6693f5adecb1ff0e1f8f6b (diff)
tdf#125692 SalObject always holds a SystemChildWindow
Let's just face reality and store it as a VclPtr. And this is needed, because Qt, like VCL, uses deferred deletion, and has no way to filter events to QObjects out of its event queue easily. This way the qt5 plugin can report focus changes for SalObjects without a crash, which happens when you close a presentation with a video by click. And in addition it reverts the workaround introduced in commit e770bacc85a0 ("Qt5 workaround modal change after show bug"), as it seems this bug is a use-after-free error, introduced by LO. Thanks Michael Weghorn for catching that! Maybe someone should also rename SalObject... Reviewed-on: https://gerrit.libreoffice.org/73567 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de> (cherry picked from commit 2dc6bdd1d5789ace0500cad90f5d2eb930888bb9) Reviewed-on: https://gerrit.libreoffice.org/73921 Change-Id: I0bc64ea64f95dfc7a838799c4a04de183adfefcf Reviewed-on: https://gerrit.libreoffice.org/73962 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
-rw-r--r--vcl/inc/salobj.hxx7
-rw-r--r--vcl/qt5/Qt5Frame.cxx20
-rw-r--r--vcl/source/window/syschild.cxx6
3 files changed, 17 insertions, 16 deletions
diff --git a/vcl/inc/salobj.hxx b/vcl/inc/salobj.hxx
index 3e8dbf152d29..af4d44e42c92 100644
--- a/vcl/inc/salobj.hxx
+++ b/vcl/inc/salobj.hxx
@@ -21,16 +21,17 @@
#define INCLUDED_VCL_INC_SALOBJ_HXX
#include <vcl/dllapi.h>
+#include <vcl/syschild.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include "salwtype.hxx"
struct SystemEnvData;
-typedef void (*SALOBJECTPROC)( void* pInst, SalObjEvent nEvent );
+typedef void (*SALOBJECTPROC)(SystemChildWindow* pInst, SalObjEvent nEvent);
class VCL_PLUGIN_PUBLIC SalObject
{
- void* m_pInst;
+ VclPtr<SystemChildWindow> m_pInst;
SALOBJECTPROC m_pCallback;
bool m_bMouseTransparent:1,
m_bEraseBackground:1;
@@ -54,7 +55,7 @@ public:
virtual const SystemEnvData* GetSystemData() const = 0;
- void SetCallback( void* pInst, SALOBJECTPROC pProc )
+ void SetCallback( SystemChildWindow* pInst, SALOBJECTPROC pProc )
{ m_pInst = pInst; m_pCallback = pProc; }
void CallCallback( SalObjEvent nEvent )
{ if (m_pCallback) m_pCallback( m_pInst, nEvent ); }
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index a47d39211ee5..6b738f159ea4 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -33,6 +33,7 @@
#include <QtCore/QMimeData>
#include <QtCore/QPoint>
#include <QtCore/QSize>
+#include <QtCore/QThread>
#include <QtGui/QIcon>
#include <QtGui/QWindow>
#include <QtGui/QScreen>
@@ -556,21 +557,18 @@ void Qt5Frame::SetModal(bool bModal)
auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
assert(pSalInst);
pSalInst->RunInMainThread([this, bModal]() {
- bool wasVisible = windowHandle()->isVisible();
+
+ QWidget* const pChild = m_pTopLevel ? m_pTopLevel : m_pQWidget;
+ const bool bWasVisible = pChild->isVisible();
// modality change is only effective if the window is hidden
- if (wasVisible)
- {
- windowHandle()->hide();
- }
+ if (bWasVisible)
+ pChild->hide();
- windowHandle()->setModality(bModal ? Qt::WindowModal : Qt::NonModal);
+ pChild->setWindowModality(bModal ? Qt::WindowModal : Qt::NonModal);
- // and shown again if it was visible
- if (wasVisible)
- {
- windowHandle()->show();
- }
+ if (bWasVisible)
+ pChild->show();
});
}
}
diff --git a/vcl/source/window/syschild.cxx b/vcl/source/window/syschild.cxx
index 28063ce19c63..e6f3e6013400 100644
--- a/vcl/source/window/syschild.cxx
+++ b/vcl/source/window/syschild.cxx
@@ -42,9 +42,9 @@
using namespace ::com::sun::star;
-static void ImplSysChildProc( void* pInst, SalObjEvent nEvent )
+static void ImplSysChildProc( SystemChildWindow* pInst, SalObjEvent nEvent )
{
- VclPtr<SystemChildWindow> pWindow = static_cast<SystemChildWindow*>(pInst);
+ VclPtr<SystemChildWindow> pWindow = pInst;
switch ( nEvent )
{
@@ -68,6 +68,8 @@ static void ImplSysChildProc( void* pInst, SalObjEvent nEvent )
case SalObjEvent::LoseFocus:
// trigger a LoseFocus which matches the status
// of the window with matching Activate-Status
+ if (pWindow->IsDisposed())
+ break;
pWindow->ImplGetFrameData()->mbSysObjFocus = false;
if ( !pWindow->ImplGetFrameData()->mnFocusId )
{