mirror of https://github.com/procxx/kepka.git
Improve clearing of DocumentMedia.
This commit is contained in:
parent
7db53599e8
commit
6ca43153bb
|
@ -28,6 +28,8 @@ public:
|
|||
|
||||
void clearStickerLoopPlayed() override {
|
||||
}
|
||||
void checkHeavyPart() override {
|
||||
}
|
||||
void unloadHeavyPart() override {
|
||||
if (_start) {
|
||||
_start->unloadHeavyPart();
|
||||
|
|
|
@ -78,14 +78,19 @@ public:
|
|||
return _attach.get();
|
||||
}
|
||||
|
||||
void parentTextUpdated() override;
|
||||
|
||||
void checkHeavyPart() override {
|
||||
if (_attach) {
|
||||
_attach->checkHeavyPart();
|
||||
}
|
||||
}
|
||||
void unloadHeavyPart() override {
|
||||
if (_attach) {
|
||||
_attach->unloadHeavyPart();
|
||||
}
|
||||
}
|
||||
|
||||
void parentTextUpdated() override;
|
||||
|
||||
~Game();
|
||||
|
||||
private:
|
||||
|
|
|
@ -66,16 +66,21 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
Media *attach() const {
|
||||
return _attach.get();
|
||||
}
|
||||
|
||||
void checkHeavyPart() override {
|
||||
if (_attach) {
|
||||
_attach->checkHeavyPart();
|
||||
}
|
||||
}
|
||||
void unloadHeavyPart() override {
|
||||
if (_attach) {
|
||||
_attach->unloadHeavyPart();
|
||||
}
|
||||
}
|
||||
|
||||
Media *attach() const {
|
||||
return _attach.get();
|
||||
}
|
||||
|
||||
private:
|
||||
QSize countOptimalSize() override;
|
||||
QSize countCurrentSize(int newWidth) override;
|
||||
|
|
|
@ -66,6 +66,8 @@ Sticker::Sticker(
|
|||
|
||||
Sticker::~Sticker() {
|
||||
unloadLottie();
|
||||
_dataMedia = nullptr;
|
||||
checkHeavyPart();
|
||||
}
|
||||
|
||||
bool Sticker::isEmojiSticker() const {
|
||||
|
@ -244,7 +246,7 @@ void Sticker::refreshLink() {
|
|||
return;
|
||||
}
|
||||
that->_lottieOncePlayed = false;
|
||||
that->_parent->data()->history()->owner().requestViewRepaint(
|
||||
that->_parent->history()->owner().requestViewRepaint(
|
||||
that->_parent);
|
||||
});
|
||||
} else if (sticker && sticker->set.type() != mtpc_inputStickerSetEmpty) {
|
||||
|
@ -260,6 +262,7 @@ void Sticker::ensureDataMediaCreated() const {
|
|||
}
|
||||
_dataMedia = _data->createMediaView();
|
||||
_dataMedia->goodThumbnailWanted();
|
||||
_parent->history()->owner().registerHeavyViewPart(_parent);
|
||||
}
|
||||
|
||||
void Sticker::setDiceIndex(const QString &emoji, int index) {
|
||||
|
@ -274,18 +277,29 @@ void Sticker::setupLottie() {
|
|||
Stickers::LottieSize::MessageHistory,
|
||||
_size * cIntRetinaFactor(),
|
||||
Lottie::Quality::High);
|
||||
_parent->data()->history()->owner().registerHeavyViewPart(_parent);
|
||||
_parent->history()->owner().registerHeavyViewPart(_parent);
|
||||
|
||||
_lottie->updates(
|
||||
) | rpl::start_with_next([=](Lottie::Update update) {
|
||||
update.data.match([&](const Lottie::Information &information) {
|
||||
_parent->data()->history()->owner().requestViewResize(_parent);
|
||||
_parent->history()->owner().requestViewResize(_parent);
|
||||
}, [&](const Lottie::DisplayFrameRequest &request) {
|
||||
_parent->data()->history()->owner().requestViewRepaint(_parent);
|
||||
_parent->history()->owner().requestViewRepaint(_parent);
|
||||
});
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
void Sticker::checkHeavyPart() {
|
||||
if (!_dataMedia && !_lottie) {
|
||||
_parent->history()->owner().unregisterHeavyViewPart(_parent);
|
||||
}
|
||||
}
|
||||
|
||||
void Sticker::unloadHeavyPart() {
|
||||
unloadLottie();
|
||||
_dataMedia = nullptr;
|
||||
}
|
||||
|
||||
void Sticker::unloadLottie() {
|
||||
if (!_lottie) {
|
||||
return;
|
||||
|
@ -295,7 +309,7 @@ void Sticker::unloadLottie() {
|
|||
_lottieOncePlayed = false;
|
||||
}
|
||||
_lottie = nullptr;
|
||||
_parent->data()->history()->owner().unregisterHeavyViewPart(_parent);
|
||||
checkHeavyPart();
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -49,9 +49,10 @@ public:
|
|||
void clearStickerLoopPlayed() override {
|
||||
_lottieOncePlayed = false;
|
||||
}
|
||||
void unloadHeavyPart() override {
|
||||
unloadLottie();
|
||||
}
|
||||
|
||||
void checkHeavyPart() override;
|
||||
void unloadHeavyPart() override;
|
||||
|
||||
void refreshLink() override;
|
||||
|
||||
void setDiceIndex(const QString &emoji, int index);
|
||||
|
|
|
@ -8,10 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/view/media/history_view_theme_document.h"
|
||||
|
||||
#include "layout.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_document_media.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "base/qthelp_url.h"
|
||||
|
@ -38,6 +40,11 @@ ThemeDocument::ThemeDocument(
|
|||
setStatusSize(FileStatusSizeReady, _data->size, -1, 0);
|
||||
}
|
||||
|
||||
ThemeDocument::~ThemeDocument() {
|
||||
_dataMedia = nullptr;
|
||||
checkHeavyPart();
|
||||
}
|
||||
|
||||
void ThemeDocument::fillPatternFieldsFrom(const QString &url) {
|
||||
const auto paramsPosition = url.indexOf('?');
|
||||
if (paramsPosition < 0) {
|
||||
|
@ -185,6 +192,7 @@ void ThemeDocument::validateThumbnail() const {
|
|||
if (!_dataMedia) {
|
||||
_dataMedia = _data->createMediaView();
|
||||
_dataMedia->goodThumbnailWanted();
|
||||
_parent->history()->owner().registerHeavyViewPart(_parent);
|
||||
}
|
||||
if (const auto good = _dataMedia->goodThumbnail()) {
|
||||
if (good->loaded()) {
|
||||
|
@ -288,4 +296,14 @@ QString ThemeDocument::additionalInfoString() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void ThemeDocument::checkHeavyPart() {
|
||||
if (!_dataMedia) {
|
||||
_parent->history()->owner().unregisterHeavyViewPart(_parent);
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeDocument::unloadHeavyPart() {
|
||||
_dataMedia = nullptr;
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> document,
|
||||
const QString &url = QString());
|
||||
~ThemeDocument();
|
||||
|
||||
void draw(
|
||||
Painter &p,
|
||||
|
@ -45,6 +46,9 @@ public:
|
|||
bool isReadyForOpen() const override;
|
||||
QString additionalInfoString() const override;
|
||||
|
||||
void checkHeavyPart() override;
|
||||
void unloadHeavyPart() override;
|
||||
|
||||
protected:
|
||||
float64 dataProgress() const override;
|
||||
bool dataFinished() const override;
|
||||
|
|
|
@ -81,16 +81,21 @@ public:
|
|||
}
|
||||
bool enforceBubbleWidth() const override;
|
||||
|
||||
Media *attach() const {
|
||||
return _attach.get();
|
||||
}
|
||||
|
||||
void checkHeavyPart() override {
|
||||
if (_attach) {
|
||||
_attach->checkHeavyPart();
|
||||
}
|
||||
}
|
||||
void unloadHeavyPart() override {
|
||||
if (_attach) {
|
||||
_attach->unloadHeavyPart();
|
||||
}
|
||||
}
|
||||
|
||||
Media *attach() const {
|
||||
return _attach.get();
|
||||
}
|
||||
|
||||
~WebPage();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue