[Libreoffice-commits] core.git: vcl/inc vcl/qt5
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 21 10:44:37 UTC 2019
vcl/inc/qt5/Qt5Object.hxx | 3 +--
vcl/qt5/Qt5Object.cxx | 10 ++++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
New commits:
commit f0c9b93e5bc7976dea5de4a49be87cc9892941a7
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Jun 21 01:49:59 2019 +0000
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Jun 21 12:43:13 2019 +0200
tdf#126020 Qt5 delete orphan Qt5ObjectWindows
The Qt5ObjectWindow is "adopted" by Qt5Frame's QWidget, which
is needed for the correct display. But since the Qt5Object is
itself a child of the Qt5Frame, it'll be deleted before the
Qt5Frame, which keeps the Qt5ObjectWindows alive.
But the Qt5ObjectWindows child relies on the Qt5Object parent,
so reap it, when the real parent is destructed.
And just in case the Qt5Frame will delete the QWidget with the
child while the Qt5Object is still alive, update the pointer to
the child on its destruction.
Change-Id: I563ddc2294b7b1651f56abdde75319c7455dd9b7
Reviewed-on: https://gerrit.libreoffice.org/74482
Tested-by: Jenkins
Reviewed-by: Aleksei Nikiforov <darktemplar at basealt.ru>
diff --git a/vcl/inc/qt5/Qt5Object.hxx b/vcl/inc/qt5/Qt5Object.hxx
index 6bfdd81b0327..c6dce6e944be 100644
--- a/vcl/inc/qt5/Qt5Object.hxx
+++ b/vcl/inc/qt5/Qt5Object.hxx
@@ -33,8 +33,6 @@ class Qt5Object : public QObject, public SalObject
{
Q_OBJECT
- friend class Qt5OpenGLContext;
-
SystemEnvData m_aSystemData;
Qt5Frame* m_pParent;
QWidget* m_pQWidget; // main widget, container
@@ -43,6 +41,7 @@ class Qt5Object : public QObject, public SalObject
public:
Qt5Object(Qt5Frame* pParent, bool bShow);
+ ~Qt5Object() override;
Qt5Frame* frame() const { return m_pParent; }
QWidget* widget() const { return m_pQWidget; }
diff --git a/vcl/qt5/Qt5Object.cxx b/vcl/qt5/Qt5Object.cxx
index 6c5238f012dc..961622eeb893 100644
--- a/vcl/qt5/Qt5Object.cxx
+++ b/vcl/qt5/Qt5Object.cxx
@@ -36,6 +36,7 @@ Qt5Object::Qt5Object(Qt5Frame* pParent, bool bShow)
m_pQWindow = new Qt5ObjectWindow(*this);
m_pQWidget = QWidget::createWindowContainer(m_pQWindow, pParent->GetQWidget());
m_pQWidget->setAttribute(Qt::WA_NoSystemBackground);
+ connect(m_pQWidget, &QObject::destroyed, this, [this]() { m_pQWidget = nullptr; });
if (bShow)
m_pQWidget->show();
@@ -65,6 +66,15 @@ Qt5Object::Qt5Object(Qt5Frame* pParent, bool bShow)
}
}
+Qt5Object::~Qt5Object()
+{
+ if (m_pQWidget)
+ {
+ m_pQWidget->setParent(nullptr);
+ delete m_pQWidget;
+ }
+}
+
void Qt5Object::ResetClipRegion()
{
if (m_pQWidget)
More information about the Libreoffice-commits
mailing list