diff --git a/CHANGELOG.md b/CHANGELOG.md index e81e87638..8235bb3bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,5 +9,6 @@ - Bugfix: Fix preview on hover not working when Animated emotes options was disabled (#1546) - Bugfix: FFZ custom mod badges no longer scale with the emote scale options (#1602) - Bugfix: MacOS updater looked for non-existing fields, causing it to always fail the update check (#1642) +- Bugfix: Fixed message menu crashing if the message you right-clicked goes out of scope before you select an action (#1783) (#1787) - Settings open faster - Dev: Fully remove Twitch Chatroom support diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index afc5d3709..25c9db436 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1570,12 +1570,12 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) } // handle the click - this->handleMouseClick(event, hoverLayoutElement, layout.get()); + this->handleMouseClick(event, hoverLayoutElement, layout); } void ChannelView::handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoveredElement, - MessageLayout *layout) + MessageLayoutPtr layout) { switch (event->button()) { @@ -1593,7 +1593,7 @@ void ChannelView::handleMouseClick(QMouseEvent *event, auto &link = hoveredElement->getLink(); if (!getSettings()->linksDoubleClickOnly) { - this->handleLinkClick(event, link, layout); + this->handleLinkClick(event, link, layout.get()); } // Invoke to signal from EmotePopup. @@ -1631,7 +1631,7 @@ void ChannelView::handleMouseClick(QMouseEvent *event, auto &link = hoveredElement->getLink(); if (!getSettings()->linksDoubleClickOnly) { - this->handleLinkClick(event, link, layout); + this->handleLinkClick(event, link, layout.get()); } } break; @@ -1640,13 +1640,15 @@ void ChannelView::handleMouseClick(QMouseEvent *event, } void ChannelView::addContextMenuItems( - const MessageLayoutElement *hoveredElement, MessageLayout *layout) + const MessageLayoutElement *hoveredElement, MessageLayoutPtr layout) { const auto &creator = hoveredElement->getCreator(); auto creatorFlags = creator.getFlags(); - static QMenu *menu = new QMenu; - menu->clear(); + auto menu = new QMenu; + connect(menu, &QMenu::aboutToHide, [menu] { + menu->deleteLater(); // + }); // Emote actions if (creatorFlags.hasAny( diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 6700ea672..1e4d764bd 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -145,9 +145,9 @@ private: void handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoverLayoutElement, - MessageLayout *layout); + MessageLayoutPtr layout); void addContextMenuItems(const MessageLayoutElement *hoveredElement, - MessageLayout *layout); + MessageLayoutPtr layout); int getLayoutWidth() const; void updatePauses(); void unpaused();