From 348cd855b9b2aafc8c51f300c8ed9e9402300e70 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 6 Oct 2026 19:06:37 +0200 Subject: [PATCH] chatgui: detach file drop callbacks before composer child destruction --- tools/chatgui/src/inputbar.cpp | 11 +++++++++++ tools/chatgui/src/inputbar.h | 1 + 2 files changed, 12 insertions(+) diff --git a/tools/chatgui/src/inputbar.cpp b/tools/chatgui/src/inputbar.cpp index 65029c47..65e30bad 100644 --- a/tools/chatgui/src/inputbar.cpp +++ b/tools/chatgui/src/inputbar.cpp @@ -214,6 +214,17 @@ InputBar::InputBar(EmojiPanel *emojiPanel, AudioRecorder *recorder, QWidget *par }); } +/* QWidget уничтожает дочерние viewport после полей InputBar: снимаем callbacks до их уничтожения. */ +InputBar::~InputBar() { + GUI_DEBUG("InputBar: removing file drop targets count=%d", int(m_dropTargets.size())); + for (auto* target : m_dropTargets) { + target->removeEventFilter(this); + disconnect(target, nullptr, this, nullptr); + } + m_dropTargets.clear(); + delete m_dropHint.data(); +} + /* Qt доставляет drop в viewport, а не в QTextEdit/QListView. Родитель composer принимает drop на кнопках. */ void InputBar::installFileDropTarget(QWidget* target) { if (!target || m_dropTargets.contains(target)) return; diff --git a/tools/chatgui/src/inputbar.h b/tools/chatgui/src/inputbar.h index 4ab1a548..6a5bcd88 100644 --- a/tools/chatgui/src/inputbar.h +++ b/tools/chatgui/src/inputbar.h @@ -22,6 +22,7 @@ class InputBar : public QWidget { public: explicit InputBar(EmojiPanel *emojiPanel, AudioRecorder *recorder, QWidget *parent = nullptr); + ~InputBar() override; void setRecordingContext(const QString& mediaDirBase, const QString& channelId); /* Один обработчик URL-drop для composer и viewport истории; отправка остаётся по кнопке/Enter. */