From a572f8a37d5ccd9aa361918c7838887681ae294e Mon Sep 17 00:00:00 2001 From: donghualin Date: Tue, 17 Jan 2023 10:38:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=8E=E6=89=98?= =?UTF-8?q?=E7=9B=98=E6=8B=96=E5=8A=A8=E5=9B=BE=E6=A0=87=E5=88=B0=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=A0=8F=E5=BC=95=E8=B5=B7=E5=B4=A9=E6=BA=83=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将static_cast修改为dynamic_cast,增加了类型判断 Log: Influence: 将托盘图标拖动到任务栏 Bug: https://pms.uniontech.com/bug-view-181945.html Change-Id: I5b23088b8b7508d9a7cf2683a3a8571a57b82e38 --- frame/drag/quickdragcore.h | 2 -- frame/window/quickpluginwindow.cpp | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/drag/quickdragcore.h b/frame/drag/quickdragcore.h index 4156a65cf..0eee58dc2 100644 --- a/frame/drag/quickdragcore.h +++ b/frame/drag/quickdragcore.h @@ -50,6 +50,4 @@ private: bool m_useSourcePixmap; }; -Q_DECLARE_INTERFACE(QuickIconDrag, "QuickIconDrag") - #endif // QUICKDRAGCORE_H diff --git a/frame/window/quickpluginwindow.cpp b/frame/window/quickpluginwindow.cpp index c8d7d600d..d3fffc94b 100644 --- a/frame/window/quickpluginwindow.cpp +++ b/frame/window/quickpluginwindow.cpp @@ -320,7 +320,9 @@ bool QuickPluginWindow::eventFilter(QObject *watched, QEvent *event) void QuickPluginWindow::dragEnterEvent(QDragEnterEvent *event) { - m_dragEnterMimeData = static_cast(const_cast(event->mimeData())); + // 由于QuickPluginMimeData和QuickIconDrag的来源是pluginManager插件,dock和插件中都使用了这两个类,但是这个两个类 + // 是各自编译的,相当于编译了两份,所以使用qobject_cast会导致转换失败,因此,此处使用dynamic_cast来保证转换成功 + m_dragEnterMimeData = dynamic_cast(const_cast(event->mimeData())); if (m_dragEnterMimeData) { PluginsItemInterface *plugin = m_dragEnterMimeData->pluginItemInterface(); QIcon icon = plugin->icon(DockPart::QuickShow); @@ -329,7 +331,7 @@ void QuickPluginWindow::dragEnterEvent(QDragEnterEvent *event) if (widget) icon = widget->grab(); } - QuickIconDrag *drag = qobject_cast(m_dragEnterMimeData->drag()); + QuickIconDrag *drag = dynamic_cast(m_dragEnterMimeData->drag()); if (drag && !icon.isNull()) { QPixmap pixmap = icon.pixmap(QSize(16, 16)); drag->updatePixmap(pixmap);