Fix crash from background access to style::icon-s.
This commit is contained in:
parent
3a1bb1966d
commit
b415b293cf
|
@ -444,7 +444,8 @@ void ChatTheme::setBubblesBackground(QImage image) {
|
||||||
_bubblesBackgroundPrepared = std::move(image);
|
_bubblesBackgroundPrepared = std::move(image);
|
||||||
if (_bubblesBackgroundPrepared.isNull()) {
|
if (_bubblesBackgroundPrepared.isNull()) {
|
||||||
_bubblesBackgroundPattern = nullptr;
|
_bubblesBackgroundPattern = nullptr;
|
||||||
_repaintBackgroundRequests.fire({});
|
// setBubblesBackground called only from background thread.
|
||||||
|
//_repaintBackgroundRequests.fire({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_bubblesBackground = CacheBackground({
|
_bubblesBackground = CacheBackground({
|
||||||
|
@ -459,7 +460,14 @@ void ChatTheme::setBubblesBackground(QImage image) {
|
||||||
_bubblesBackgroundPattern = PrepareBubblePattern(palette());
|
_bubblesBackgroundPattern = PrepareBubblePattern(palette());
|
||||||
}
|
}
|
||||||
_bubblesBackgroundPattern->pixmap = _bubblesBackground.pixmap;
|
_bubblesBackgroundPattern->pixmap = _bubblesBackground.pixmap;
|
||||||
_repaintBackgroundRequests.fire({});
|
// setBubblesBackground called only from background thread.
|
||||||
|
//_repaintBackgroundRequests.fire({});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatTheme::finishCreateOnMain() {
|
||||||
|
if (_bubblesBackgroundPattern) {
|
||||||
|
FinishBubblePatternOnMain(_bubblesBackgroundPattern.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatPaintContext ChatTheme::preparePaintContext(
|
ChatPaintContext ChatTheme::preparePaintContext(
|
||||||
|
|
|
@ -163,6 +163,7 @@ public:
|
||||||
[[nodiscard]] const BubblePattern *bubblesBackgroundPattern() const {
|
[[nodiscard]] const BubblePattern *bubblesBackgroundPattern() const {
|
||||||
return _bubblesBackgroundPattern.get();
|
return _bubblesBackgroundPattern.get();
|
||||||
}
|
}
|
||||||
|
void finishCreateOnMain(); // Called on_main after setBubblesBackground.
|
||||||
|
|
||||||
[[nodiscard]] ChatPaintContext preparePaintContext(
|
[[nodiscard]] ChatPaintContext preparePaintContext(
|
||||||
not_null<const ChatStyle*> st,
|
not_null<const ChatStyle*> st,
|
||||||
|
|
|
@ -266,11 +266,6 @@ std::unique_ptr<BubblePattern> PrepareBubblePattern(
|
||||||
};
|
};
|
||||||
addShadow(result->corners[2]);
|
addShadow(result->corners[2]);
|
||||||
addShadow(result->corners[3]);
|
addShadow(result->corners[3]);
|
||||||
result->tailLeft = st::historyBubbleTailOutLeft.instance(Qt::white);
|
|
||||||
result->tailRight = st::historyBubbleTailOutRight.instance(Qt::white);
|
|
||||||
result->tailCache = QImage(
|
|
||||||
result->tailLeft.size(),
|
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
|
||||||
result->cornerTopCache = QImage(
|
result->cornerTopCache = QImage(
|
||||||
result->corners[0].size(),
|
result->corners[0].size(),
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
@ -280,6 +275,14 @@ std::unique_ptr<BubblePattern> PrepareBubblePattern(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FinishBubblePatternOnMain(not_null<BubblePattern*> pattern) {
|
||||||
|
pattern->tailLeft = st::historyBubbleTailOutLeft.instance(Qt::white);
|
||||||
|
pattern->tailRight = st::historyBubbleTailOutRight.instance(Qt::white);
|
||||||
|
pattern->tailCache = QImage(
|
||||||
|
pattern->tailLeft.size(),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
}
|
||||||
|
|
||||||
void PaintBubble(Painter &p, const SimpleBubble &args) {
|
void PaintBubble(Painter &p, const SimpleBubble &args) {
|
||||||
if (!args.selected
|
if (!args.selected
|
||||||
&& args.outbg
|
&& args.outbg
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct BubblePattern {
|
||||||
|
|
||||||
[[nodiscard]] std::unique_ptr<BubblePattern> PrepareBubblePattern(
|
[[nodiscard]] std::unique_ptr<BubblePattern> PrepareBubblePattern(
|
||||||
not_null<const style::palette*> st);
|
not_null<const style::palette*> st);
|
||||||
|
void FinishBubblePatternOnMain(not_null<BubblePattern*> pattern);
|
||||||
|
|
||||||
struct SimpleBubble {
|
struct SimpleBubble {
|
||||||
not_null<const ChatStyle*> st;
|
not_null<const ChatStyle*> st;
|
||||||
|
|
|
@ -1632,6 +1632,7 @@ void SessionController::cacheChatTheme(
|
||||||
this,
|
this,
|
||||||
result = std::make_shared<Ui::ChatTheme>(std::move(descriptor))
|
result = std::make_shared<Ui::ChatTheme>(std::move(descriptor))
|
||||||
]() mutable {
|
]() mutable {
|
||||||
|
result->finishCreateOnMain();
|
||||||
cacheChatThemeDone(std::move(result));
|
cacheChatThemeDone(std::move(result));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue