mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Don't crash on corrupt animated images
This commit is contained in:
parent
d839204640
commit
e4f8d32a72
1 changed files with 19 additions and 14 deletions
|
@ -70,6 +70,7 @@ MxcAnimatedImage::startDownload()
|
||||||
if (!self)
|
if (!self)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
if (buffer.isOpen()) {
|
if (buffer.isOpen()) {
|
||||||
movie.stop();
|
movie.stop();
|
||||||
movie.setDevice(nullptr);
|
movie.setDevice(nullptr);
|
||||||
|
@ -79,13 +80,17 @@ MxcAnimatedImage::startDownload()
|
||||||
if (encryptionInfo) {
|
if (encryptionInfo) {
|
||||||
QByteArray ba = device.readAll();
|
QByteArray ba = device.readAll();
|
||||||
std::string temp(ba.constData(), ba.size());
|
std::string temp(ba.constData(), ba.size());
|
||||||
temp = mtx::crypto::to_string(mtx::crypto::decrypt_file(temp, encryptionInfo.value()));
|
temp =
|
||||||
|
mtx::crypto::to_string(mtx::crypto::decrypt_file(temp, encryptionInfo.value()));
|
||||||
buffer.setData(temp.data(), temp.size());
|
buffer.setData(temp.data(), temp.size());
|
||||||
} else {
|
} else {
|
||||||
buffer.setData(device.readAll());
|
buffer.setData(device.readAll());
|
||||||
}
|
}
|
||||||
buffer.open(QIODevice::ReadOnly);
|
buffer.open(QIODevice::ReadOnly);
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
nhlog::net()->error("Failed to setup animated image buffer: {}", e.what());
|
||||||
|
}
|
||||||
|
|
||||||
QTimer::singleShot(0, this, [this, mimeType] {
|
QTimer::singleShot(0, this, [this, mimeType] {
|
||||||
nhlog::ui()->info(
|
nhlog::ui()->info(
|
||||||
|
|
Loading…
Reference in a new issue