mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixes for last commit
This commit is contained in:
parent
aac27c2a0d
commit
e7d9422431
5 changed files with 56 additions and 14 deletions
|
@ -6,10 +6,15 @@
|
||||||
|
|
||||||
namespace AB_NAMESPACE {
|
namespace AB_NAMESPACE {
|
||||||
|
|
||||||
|
static bool isGuiThread()
|
||||||
|
{
|
||||||
|
return QCoreApplication::instance()->thread() == QThread::currentThread();
|
||||||
|
}
|
||||||
|
|
||||||
static void assertInGuiThread()
|
static void assertInGuiThread()
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
assert(QCoreApplication::instance()->thread() == QThread::currentThread());
|
assert(isGuiThread());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,14 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Iterator &operator=(const Iterator &other)
|
||||||
|
{
|
||||||
|
this->lock_ = std::shared_lock(other.mutex_.get());
|
||||||
|
this->mutex_ = other.mutex_;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
TVectorItem &operator*()
|
TVectorItem &operator*()
|
||||||
{
|
{
|
||||||
return it_.operator*();
|
return it_.operator*();
|
||||||
|
@ -69,7 +77,7 @@ public:
|
||||||
private:
|
private:
|
||||||
VecIt it_;
|
VecIt it_;
|
||||||
std::shared_lock<std::shared_mutex> lock_;
|
std::shared_lock<std::shared_mutex> lock_;
|
||||||
std::shared_mutex &mutex_;
|
std::reference_wrapper<std::shared_mutex> mutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
ReadOnlySignalVector()
|
ReadOnlySignalVector()
|
||||||
|
@ -113,6 +121,13 @@ public:
|
||||||
return this->vector_;
|
return this->vector_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<TVectorItem> cloneVector() const
|
||||||
|
{
|
||||||
|
std::shared_lock lock(this->mutex_);
|
||||||
|
|
||||||
|
return this->vector_;
|
||||||
|
}
|
||||||
|
|
||||||
void invokeDelayedItemsChanged()
|
void invokeDelayedItemsChanged()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
|
@ -221,7 +221,11 @@ ImagePtr Image::fromUrl(const Url &url, qreal scale)
|
||||||
|
|
||||||
ImagePtr Image::fromPixmap(const QPixmap &pixmap, qreal scale)
|
ImagePtr Image::fromPixmap(const QPixmap &pixmap, qreal scale)
|
||||||
{
|
{
|
||||||
return ImagePtr(new Image(pixmap, scale));
|
auto result = ImagePtr(new Image(scale));
|
||||||
|
|
||||||
|
result->setPixmap(pixmap);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImagePtr Image::getEmpty()
|
ImagePtr Image::getEmpty()
|
||||||
|
@ -243,13 +247,29 @@ Image::Image(const Url &url, qreal scale)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Image(const QPixmap &pixmap, qreal scale)
|
Image::Image(qreal scale)
|
||||||
: scale_(scale)
|
: scale_(scale)
|
||||||
, frames_(std::make_unique<detail::Frames>(
|
, frames_(std::make_unique<detail::Frames>())
|
||||||
QVector<detail::Frame<QPixmap>>{detail::Frame<QPixmap>{pixmap, 1}}))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Image::setPixmap(const QPixmap &pixmap)
|
||||||
|
{
|
||||||
|
auto setFrames = [shared = this->shared_from_this(), pixmap]() {
|
||||||
|
shared->frames_ = std::make_unique<detail::Frames>(
|
||||||
|
QVector<detail::Frame<QPixmap>>{detail::Frame<QPixmap>{pixmap, 1}});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isGuiThread())
|
||||||
|
{
|
||||||
|
setFrames();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
postToThread(setFrames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Url &Image::url() const
|
const Url &Image::url() const
|
||||||
{
|
{
|
||||||
return this->url_;
|
return this->url_;
|
||||||
|
|
|
@ -66,7 +66,9 @@ public:
|
||||||
private:
|
private:
|
||||||
Image();
|
Image();
|
||||||
Image(const Url &url, qreal scale);
|
Image(const Url &url, qreal scale);
|
||||||
Image(const QPixmap &nonOwning, qreal scale);
|
Image(qreal scale);
|
||||||
|
|
||||||
|
void setPixmap(const QPixmap &pixmap);
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
|
|
@ -796,19 +796,19 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||||
? QUrl::fromLocalFile(getSettings()->pathHighlightSound.getValue())
|
? QUrl::fromLocalFile(getSettings()->pathHighlightSound.getValue())
|
||||||
: QUrl("qrc:/sounds/ping2.wav");
|
: QUrl("qrc:/sounds/ping2.wav");
|
||||||
|
|
||||||
if (currentPlayerUrl != highlightSoundUrl)
|
// if (currentPlayerUrl != highlightSoundUrl)
|
||||||
{
|
// {
|
||||||
player->setMedia(highlightSoundUrl);
|
// player->setMedia(highlightSoundUrl);
|
||||||
|
|
||||||
currentPlayerUrl = highlightSoundUrl;
|
// currentPlayerUrl = highlightSoundUrl;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// TODO: This vector should only be rebuilt upon highlights being changed
|
// TODO: This vector should only be rebuilt upon highlights being changed
|
||||||
// fourtf: should be implemented in the HighlightsController
|
// fourtf: should be implemented in the HighlightsController
|
||||||
std::vector<HighlightPhrase> activeHighlights =
|
std::vector<HighlightPhrase> activeHighlights =
|
||||||
app->highlights->phrases.getVector();
|
app->highlights->phrases.cloneVector();
|
||||||
std::vector<HighlightPhrase> userHighlights =
|
std::vector<HighlightPhrase> userHighlights =
|
||||||
app->highlights->highlightedUsers.getVector();
|
app->highlights->highlightedUsers.cloneVector();
|
||||||
|
|
||||||
if (getSettings()->enableSelfHighlight && currentUsername.size() > 0)
|
if (getSettings()->enableSelfHighlight && currentUsername.size() > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue