[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/inc vcl/qt5 vcl/source

2019-06-13 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/salobj.hxx |7 ---
 vcl/qt5/Qt5Frame.cxx   |   20 +---
 vcl/source/window/syschild.cxx |6 --
 3 files changed, 17 insertions(+), 16 deletions(-)

New commits:
commit c9e626df57a3dd66613ec6b41a7d1ffb8da1843e
Author: Jan-Marek Glogowski 
AuthorDate: Sun Jun 2 21:01:33 2019 +
Commit: Michael Weghorn 
CommitDate: Thu Jun 13 19:46:59 2019 +0200

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 
(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 
Tested-by: Jenkins

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 
+#include 
 #include 
 #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 m_pInst;
 SALOBJECTPROC   m_pCallback;
 boolm_bMouseTransparent:1,
 m_bEraseBackground:1;
@@ -54,7 +55,7 @@ public:
 
 virtual const SystemEnvData*GetSystemData() const = 0;
 
-voidSetCallback( void* pInst, SALOBJECTPROC 
pProc )
+voidSetCallback( SystemChildWindow* pInst, 
SALOBJECTPROC pProc )
 { m_pInst = pInst; m_pCallback = 
pProc; }
 voidCallCallback( 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 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -556,21 +557,18 @@ void Qt5Frame::SetModal(bool bModal)
 auto* pSalInst(static_cast(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 pWindow = static_cast(pInst);
+VclPtr 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 )
 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/inc vcl/qt5 vcl/source

2019-04-01 Thread Aleksei Nikiforov (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx  |2 ++
 vcl/qt5/Qt5Instance.cxx  |   12 ++--
 vcl/source/window/dialog.cxx |4 ++--
 3 files changed, 14 insertions(+), 4 deletions(-)

New commits:
commit d622be2d6bcfcc2c7260421e0eaa09c76ce15da2
Author: Aleksei Nikiforov 
AuthorDate: Wed Mar 6 16:10:17 2019 +0300
Commit: Thorsten Behrens 
CommitDate: Tue Apr 2 01:59:19 2019 +0200

tdf#123406 KDE5: Update delayed frame destruction

Move deleteLater() call to the different event loop.
This fixes issue with frames not being disposed of
deterministically, and previously opened window
not reactivating.

Also hide modal dialog window before unsetting modal mode.
Unsetting modal mode may require to toggle window visibility.
Window will be hidden soon anyway,
and additional generated events might make finding correct
focused window harder.

Change-Id: Id7839f817075785287b09f6ac79eb3fb211726aa
Reviewed-on: https://gerrit.libreoffice.org/68852
Tested-by: Jenkins
Reviewed-by: Katarina Behrens 
Reviewed-on: https://gerrit.libreoffice.org/70078
Reviewed-by: Thorsten Behrens 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 91682bd87950..cece484b0316 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -50,10 +50,12 @@ public:
 
 private Q_SLOTS:
 bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
+static void deleteObjectLater(QObject* pObject);
 
 Q_SIGNALS:
 bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
 std::unique_ptr createMenuSignal(bool, Menu*);
+void deleteObjectLaterSignal(QObject* pObject);
 
 public:
 explicit Qt5Instance(bool bUseCairo = false);
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 8de9fc7f5712..58f93fea73c6 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -67,6 +67,12 @@ Qt5Instance::Qt5Instance(bool bUseCairo)
 Qt::BlockingQueuedConnection);
 connect(this, ::createMenuSignal, this, 
::CreateMenu,
 Qt::BlockingQueuedConnection);
+
+// this one needs to be queued non-blocking
+// in order to have this event arriving to correct event processing loop
+connect(this, ::deleteObjectLaterSignal, this,
+[](QObject* pObject) { Qt5Instance::deleteObjectLater(pObject); },
+Qt::QueuedConnection);
 }
 
 Qt5Instance::~Qt5Instance()
@@ -78,6 +84,8 @@ Qt5Instance::~Qt5Instance()
 free(m_pFakeArgvFreeable[i]);
 }
 
+void Qt5Instance::deleteObjectLater(QObject* pObject) { 
pObject->deleteLater(); }
+
 SalFrame* Qt5Instance::CreateChildFrame(SystemParentData* /*pParent*/, 
SalFrameStyleFlags nStyle)
 {
 return new Qt5Frame(nullptr, nStyle, m_bUseCairo);
@@ -94,7 +102,7 @@ void Qt5Instance::DestroyFrame(SalFrame* pFrame)
 if (pFrame)
 {
 assert(dynamic_cast(pFrame));
-static_cast(pFrame)->deleteLater();
+Q_EMIT deleteObjectLaterSignal(static_cast(pFrame));
 }
 }
 
@@ -109,7 +117,7 @@ void Qt5Instance::DestroyObject(SalObject* pObject)
 if (pObject)
 {
 assert(dynamic_cast(pObject));
-static_cast(pObject)->deleteLater();
+Q_EMIT deleteObjectLaterSignal(static_cast(pObject));
 }
 }
 
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 0c75f85ae8d3..168816392a30 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1097,6 +1097,8 @@ void Dialog::EndDialog( long nResult )
 
 const bool bModal = GetType() != WindowType::MODELESSDIALOG;
 
+Hide();
+
 if (bModal)
 {
 SetModalInputMode(false);
@@ -1121,8 +1123,6 @@ void Dialog::EndDialog( long nResult )
 }
 }
 
-Hide();
-
 if (bModal && GetParent())
 {
 NotifyEvent aNEvt( MouseNotifyEvent::ENDEXECUTEDIALOG, this );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/inc vcl/qt5 vcl/source

2019-02-28 Thread Libreoffice Gerrit user
 vcl/inc/qt5/Qt5Menu.hxx|2 
 vcl/inc/salmenu.hxx|1 
 vcl/qt5/Qt5Menu.cxx|   92 +
 vcl/source/window/menu.cxx |   12 -
 4 files changed, 82 insertions(+), 25 deletions(-)

New commits:
commit e14015edd9fb090bf7444f850dff42c84321bb35
Author: Aleksei Nikiforov 
AuthorDate: Wed Feb 27 15:03:07 2019 +0300
Commit: Michael Weghorn 
CommitDate: Thu Feb 28 09:27:56 2019 +0100

tdf#121970 KDE5: Regenerate menu when it's set as submenu

Also add item bits change notification function
for SalMenu to properly convert regenerated menu items
to check or radiocheck items.

Change-Id: I61f16a771b484644bbefd9afaf2776232d38a2f9
Reviewed-on: https://gerrit.libreoffice.org/68438
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit f341921825370fb98ad896a20d823c5f0cb537f6)
Reviewed-on: https://gerrit.libreoffice.org/68458
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index ea4369263f62..1ad62a82b9bd 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -39,6 +39,7 @@ private:
 
 void ReinitializeActionGroup(unsigned nPos);
 void ResetAllActionGroups();
+void UpdateActionGroupItem(Qt5MenuItem* pSalMenuItem);
 
 public:
 Qt5Menu(bool bMenuBar);
@@ -51,6 +52,7 @@ public:
 virtual void SetFrame(const SalFrame* pFrame) override;
 const Qt5Frame* GetFrame() const;
 Qt5Menu* GetTopLevel();
+virtual void SetItemBits(unsigned nPos, MenuItemBits nBits) override;
 virtual void CheckItem(unsigned nPos, bool bCheck) override;
 virtual void EnableItem(unsigned nPos, bool bEnable) override;
 virtual void ShowItem(unsigned nPos, bool bShow) override;
diff --git a/vcl/inc/salmenu.hxx b/vcl/inc/salmenu.hxx
index 0b6cd9e22481..6829e3a623d1 100644
--- a/vcl/inc/salmenu.hxx
+++ b/vcl/inc/salmenu.hxx
@@ -68,6 +68,7 @@ public:
 virtual void RemoveItem( unsigned nPos ) = 0;
 virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, 
unsigned nPos ) = 0;
 virtual void SetFrame( const SalFrame* pFrame ) = 0;
+virtual void SetItemBits( unsigned /*nPos*/, MenuItemBits /*nBits*/ ) {}
 virtual void CheckItem( unsigned nPos, bool bCheck ) = 0;
 virtual void EnableItem( unsigned nPos, bool bEnable ) = 0;
 virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const 
OUString& rText )= 0;
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 049d90b7b4da..a00cce02dffa 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -40,8 +40,6 @@ QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, 
unsigned nPos)
 OUString aText = mpVCLMenu->GetItemText(nId);
 NativeItemText(aText);
 vcl::KeyCode nAccelKey = mpVCLMenu->GetAccelKey(nId);
-bool bChecked = mpVCLMenu->IsItemChecked(nId);
-MenuItemBits itemBits = mpVCLMenu->GetItemBits(nId);
 
 pSalMenuItem->mpAction.reset();
 pSalMenuItem->mpMenu.reset();
@@ -138,24 +136,9 @@ QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, 
unsigned nPos)
 
 ReinitializeActionGroup(nPos);
 
-
pAction->setShortcut(toQString(nAccelKey.GetName(GetFrame()->GetWindow(;
+UpdateActionGroupItem(pSalMenuItem);
 
-if (itemBits & MenuItemBits::CHECKABLE)
-{
-pAction->setCheckable(true);
-pAction->setChecked(bChecked);
-}
-else if (itemBits & MenuItemBits::RADIOCHECK)
-{
-pAction->setCheckable(true);
-
-if (pSalMenuItem->mpActionGroup)
-{
-pSalMenuItem->mpActionGroup->addAction(pAction);
-}
-
-pAction->setChecked(bChecked);
-}
+
pAction->setShortcut(toQString(nAccelKey.GetName(GetFrame()->GetWindow(;
 
 connect(pAction, ::triggered, this,
 [pSalMenuItem] { slotMenuTriggered(pSalMenuItem); });
@@ -297,6 +280,43 @@ void Qt5Menu::ResetAllActionGroups()
 }
 }
 
+void Qt5Menu::UpdateActionGroupItem(Qt5MenuItem* pSalMenuItem)
+{
+QAction* pAction = pSalMenuItem->getAction();
+if (!pAction)
+return;
+
+bool bChecked = mpVCLMenu->IsItemChecked(pSalMenuItem->mnId);
+MenuItemBits itemBits = mpVCLMenu->GetItemBits(pSalMenuItem->mnId);
+
+if (itemBits & MenuItemBits::RADIOCHECK)
+{
+pAction->setCheckable(true);
+
+if (pSalMenuItem->mpActionGroup)
+{
+pSalMenuItem->mpActionGroup->addAction(pAction);
+}
+
+pAction->setChecked(bChecked);
+}
+else
+{
+pAction->setActionGroup(nullptr);
+
+if (itemBits & MenuItemBits::CHECKABLE)
+{
+pAction->setCheckable(true);
+