mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix another link-resolver related crash (non auto url unshort-related)
This commit is contained in:
parent
6ee7b1ef1f
commit
5497fec839
4 changed files with 17 additions and 2 deletions
|
@ -196,6 +196,11 @@ MessagePtr MessageBuilder::release()
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::weak_ptr<Message> MessageBuilder::weakOf()
|
||||||
|
{
|
||||||
|
return this->message_;
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBuilder::append(std::unique_ptr<MessageElement> element)
|
void MessageBuilder::append(std::unique_ptr<MessageElement> element)
|
||||||
{
|
{
|
||||||
this->message().elements.push_back(std::move(element));
|
this->message().elements.push_back(std::move(element));
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
Message *operator->();
|
Message *operator->();
|
||||||
Message &message();
|
Message &message();
|
||||||
MessagePtr release();
|
MessagePtr release();
|
||||||
|
std::weak_ptr<Message> weakOf();
|
||||||
|
|
||||||
void append(std::unique_ptr<MessageElement> element);
|
void append(std::unique_ptr<MessageElement> element);
|
||||||
QString matchLink(const QString &string);
|
QString matchLink(const QString &string);
|
||||||
|
|
|
@ -15,6 +15,8 @@ void LinkResolver::getLinkInfo(
|
||||||
QString requestUrl("https://braize.pajlada.com/chatterino/link_resolver/" +
|
QString requestUrl("https://braize.pajlada.com/chatterino/link_resolver/" +
|
||||||
QUrl::toPercentEncoding(url, "", "/:"));
|
QUrl::toPercentEncoding(url, "", "/:"));
|
||||||
|
|
||||||
|
// Uncomment to test crashes
|
||||||
|
// QTimer::singleShot(3000, [=]() {
|
||||||
NetworkRequest request(requestUrl);
|
NetworkRequest request(requestUrl);
|
||||||
request.setCaller(QThread::currentThread());
|
request.setCaller(QThread::currentThread());
|
||||||
request.setTimeout(30000);
|
request.setTimeout(30000);
|
||||||
|
@ -48,6 +50,7 @@ void LinkResolver::getLinkInfo(
|
||||||
});
|
});
|
||||||
|
|
||||||
request.execute();
|
request.execute();
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -544,8 +544,14 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||||
->setLink(link);
|
->setLink(link);
|
||||||
|
|
||||||
LinkResolver::getLinkInfo(
|
LinkResolver::getLinkInfo(
|
||||||
linkString, [linkMELowercase, linkMEOriginal, linkString](
|
linkString,
|
||||||
QString tooltipText, Link originalLink) {
|
[weakMessage = this->weakOf(), linkMELowercase, linkMEOriginal,
|
||||||
|
linkString](QString tooltipText, Link originalLink) {
|
||||||
|
auto shared = weakMessage.lock();
|
||||||
|
if (!shared)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!tooltipText.isEmpty())
|
if (!tooltipText.isEmpty())
|
||||||
{
|
{
|
||||||
linkMELowercase->setTooltip(tooltipText);
|
linkMELowercase->setTooltip(tooltipText);
|
||||||
|
|
Loading…
Reference in a new issue