Make opening threads from a usercard opened with /usercard not crash the client (#3905)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
- Major: Added support for Twitch's Chat Replies. [Wiki Page](https://wiki.chatterino.com/Features/#message-replies) (#3722, #3989, #4041, #4047, #4055, #4067, #4077)
|
- Major: Added support for Twitch's Chat Replies. [Wiki Page](https://wiki.chatterino.com/Features/#message-replies) (#3722, #3989, #4041, #4047, #4055, #4067, #4077, #3905)
|
||||||
- Major: Added multi-channel searching to search dialog via keyboard shortcut. (Ctrl+Shift+F by default) (#3694, #3875)
|
- Major: Added multi-channel searching to search dialog via keyboard shortcut. (Ctrl+Shift+F by default) (#3694, #3875)
|
||||||
- Major: Added support for emotes and badges from [7TV](https://7tv.app). [Wiki Page](https://wiki.chatterino.com/Third_party_services/#7tv) (#4002, #4062)
|
- Major: Added support for emotes and badges from [7TV](https://7tv.app). [Wiki Page](https://wiki.chatterino.com/Third_party_services/#7tv) (#4002, #4062)
|
||||||
- Minor: Added highlights for `Elevated Messages`. (#4016)
|
- Minor: Added highlights for `Elevated Messages`. (#4016)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "widgets/dialogs/ReplyThreadPopup.hpp"
|
#include "widgets/dialogs/ReplyThreadPopup.hpp"
|
||||||
#include "widgets/dialogs/UserInfoPopup.hpp"
|
#include "widgets/dialogs/UserInfoPopup.hpp"
|
||||||
#include "widgets/splits/Split.hpp"
|
#include "widgets/splits/Split.hpp"
|
||||||
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
@@ -838,10 +839,49 @@ void CommandController::initialize(Settings &, Paths &paths)
|
|||||||
channel = channelTemp;
|
channel = channelTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try to link to current split if possible
|
||||||
|
Split *currentSplit = nullptr;
|
||||||
|
auto *currentPage = dynamic_cast<SplitContainer *>(
|
||||||
|
getApp()->windows->getMainWindow().getNotebook().getSelectedPage());
|
||||||
|
if (currentPage != nullptr)
|
||||||
|
{
|
||||||
|
currentSplit = currentPage->getSelectedSplit();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto differentChannel =
|
||||||
|
currentSplit != nullptr && currentSplit->getChannel() != channel;
|
||||||
|
if (differentChannel || currentSplit == nullptr)
|
||||||
|
{
|
||||||
|
// not possible to use current split, try searching for one
|
||||||
|
const auto ¬ebook =
|
||||||
|
getApp()->windows->getMainWindow().getNotebook();
|
||||||
|
auto count = notebook.getPageCount();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
auto *page = notebook.getPageAt(i);
|
||||||
|
auto *container = dynamic_cast<SplitContainer *>(page);
|
||||||
|
assert(container != nullptr);
|
||||||
|
for (auto *split : container->getSplits())
|
||||||
|
{
|
||||||
|
if (split->getChannel() == channel)
|
||||||
|
{
|
||||||
|
currentSplit = split;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This would have crashed either way.
|
||||||
|
assert(currentSplit != nullptr &&
|
||||||
|
"something went HORRIBLY wrong with the /usercard "
|
||||||
|
"command. It couldn't find a split for a channel which "
|
||||||
|
"should be open.");
|
||||||
|
}
|
||||||
|
|
||||||
auto *userPopup = new UserInfoPopup(
|
auto *userPopup = new UserInfoPopup(
|
||||||
getSettings()->autoCloseUserPopup,
|
getSettings()->autoCloseUserPopup,
|
||||||
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())),
|
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())),
|
||||||
nullptr);
|
currentSplit);
|
||||||
userPopup->setData(userName, channel);
|
userPopup->setData(userName, channel);
|
||||||
userPopup->move(QCursor::pos());
|
userPopup->move(QCursor::pos());
|
||||||
userPopup->show();
|
userPopup->show();
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent,
|
|||||||
: DraggablePopup(closeAutomatically, parent)
|
: DraggablePopup(closeAutomatically, parent)
|
||||||
, split_(split)
|
, split_(split)
|
||||||
{
|
{
|
||||||
|
assert(split != nullptr &&
|
||||||
|
"split being nullptr causes lots of bugs down the road");
|
||||||
this->setWindowTitle("Usercard");
|
this->setWindowTitle("Usercard");
|
||||||
this->setStayInScreenRect(true);
|
this->setStayInScreenRect(true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user