vcl/CustomTarget_qt5_moc.mk | 1 + vcl/CustomTarget_qt6_moc.mk | 1 + vcl/inc/qt5/QtDragAndDrop.hxx | 7 ++++++- vcl/inc/qt5/QtFrame.hxx | 3 ++- vcl/qt5/QtDragAndDrop.cxx | 9 +++++---- 5 files changed, 15 insertions(+), 6 deletions(-)
New commits: commit 8375a74086ac24f9e53b9c573d8c04ace99c14c5 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jun 27 15:40:20 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jun 27 19:45:38 2025 +0200 qt: Use QPointer for QtFrame::m_pDropTarget This makes sure this is never going to be a dangling pointer, because it will be cleared when the QtDropTarget gets destroyed (see [1]). No issues seen in practice so far, but at least for the gtk3 implementation, the GtkInstDropTarget dtor explicitly unsets the drop target in the GtkFrame. This commit effectively does the same for qt5/qt6 without having to do so manually. [1] https://doc.qt.io/qt-6/qpointer.html Change-Id: Idcafdcb571c218fba30f01a0ccca8438e5b258a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187113 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 0eaaeb169ff8..782040d18ac2 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -32,6 +32,7 @@ #include <vcl/sysdata.hxx> #include <QtCore/QObject> +#include <QtCore/QPointer> #if !defined EMSCRIPTEN #include <unx/sessioninhibitor.hxx> @@ -93,7 +94,7 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame SystemEnvData m_aSystemData; QtDragSource* m_pDragSource; - QtDropTarget* m_pDropTarget; + QPointer<QtDropTarget> m_pDropTarget; bool m_bInDrag; bool m_bDefaultSize; commit d257afba4d14de45d344677a50065d32fabbbdf0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jun 27 15:38:59 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jun 27 19:45:29 2025 +0200 qt: Make QtDropTarget a QObject This will allow to switch QtFrame::m_pDropTarget to a QPointer in an upcoming commit. Change-Id: Ic36b25a524a880d3d04805dbd1fde1ef80b17ca6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187112 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk index 2a9ede0947ba..886799a07af3 100644 --- a/vcl/CustomTarget_qt5_moc.mk +++ b/vcl/CustomTarget_qt5_moc.mk @@ -13,6 +13,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \ $(gb_CustomTarget_workdir)/vcl/qt5/QtAccessibleWidget.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtClipboard.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtDoubleSpinBox.moc \ + $(gb_CustomTarget_workdir)/vcl/qt5/QtDragAndDrop.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtExpander.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtFilePicker.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtFrame.moc \ diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk index 08638dfc7d73..d5e1964f0bff 100644 --- a/vcl/CustomTarget_qt6_moc.mk +++ b/vcl/CustomTarget_qt6_moc.mk @@ -13,6 +13,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \ $(gb_CustomTarget_workdir)/vcl/qt6/QtAccessibleWidget.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtClipboard.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtDoubleSpinBox.moc \ + $(gb_CustomTarget_workdir)/vcl/qt6/QtDragAndDrop.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtExpander.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtFilePicker.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtFrame.moc \ diff --git a/vcl/inc/qt5/QtDragAndDrop.hxx b/vcl/inc/qt5/QtDragAndDrop.hxx index ada52e4e90c7..ed9d0dd5050c 100644 --- a/vcl/inc/qt5/QtDragAndDrop.hxx +++ b/vcl/inc/qt5/QtDragAndDrop.hxx @@ -15,6 +15,8 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/compbase.hxx> +#include <QtCore/QObject> + class QtFrame; class QtDragSource final : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource, @@ -48,10 +50,13 @@ public: }; class QtDropTarget final - : public cppu::WeakComponentImplHelper< + : public QObject, + public cppu::WeakComponentImplHelper< css::datatransfer::dnd::XDropTarget, css::datatransfer::dnd::XDropTargetDragContext, css::datatransfer::dnd::XDropTargetDropContext, css::lang::XServiceInfo> { + Q_OBJECT + osl::Mutex m_aMutex; sal_Int8 m_nDropAction; bool m_bActive; diff --git a/vcl/qt5/QtDragAndDrop.cxx b/vcl/qt5/QtDragAndDrop.cxx index 7da39b9da213..03b1214da847 100644 --- a/vcl/qt5/QtDragAndDrop.cxx +++ b/vcl/qt5/QtDragAndDrop.cxx @@ -7,14 +7,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * */ - -#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> -#include <cppuhelper/supportsservice.hxx> - #include <QtDragAndDrop.hxx> +#include <QtDragAndDrop.moc> + #include <QtFrame.hxx> #include <QtTransferable.hxx> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> +#include <cppuhelper/supportsservice.hxx> + #include <QtGui/QDrag> using namespace com::sun::star;