mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add some assertions to debug a crash.
This commit is contained in:
parent
5c44b851fe
commit
132f127f3f
2 changed files with 16 additions and 5 deletions
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Editor {
|
namespace Editor {
|
||||||
|
|
||||||
QImage ImageModified(QImage image, const PhotoModifications &mods) {
|
QImage ImageModified(QImage image, const PhotoModifications &mods) {
|
||||||
|
Expects(!image.isNull());
|
||||||
|
|
||||||
if (!mods) {
|
if (!mods) {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ bool HasExtensionFrom(const QString &file, const QStringList &extensions) {
|
||||||
bool ValidPhotoForAlbum(
|
bool ValidPhotoForAlbum(
|
||||||
const Image &image,
|
const Image &image,
|
||||||
const QString &mime) {
|
const QString &mime) {
|
||||||
|
Expects(!image.data.isNull());
|
||||||
|
|
||||||
if (image.animated
|
if (image.animated
|
||||||
|| Core::IsMimeSticker(mime)
|
|| Core::IsMimeSticker(mime)
|
||||||
|| (!mime.isEmpty() && !mime.startsWith(u"image/"))) {
|
|| (!mime.isEmpty() && !mime.startsWith(u"image/"))) {
|
||||||
|
@ -228,6 +230,8 @@ PreparedList PrepareMediaFromImage(
|
||||||
QImage &&image,
|
QImage &&image,
|
||||||
QByteArray &&content,
|
QByteArray &&content,
|
||||||
int previewWidth) {
|
int previewWidth) {
|
||||||
|
Expects(!image.isNull());
|
||||||
|
|
||||||
auto result = PreparedList();
|
auto result = PreparedList();
|
||||||
auto file = PreparedFile(QString());
|
auto file = PreparedFile(QString());
|
||||||
file.content = content;
|
file.content = content;
|
||||||
|
@ -288,6 +292,7 @@ void PrepareDetails(PreparedFile &file, int previewWidth) {
|
||||||
using Song = PreparedFileInformation::Song;
|
using Song = PreparedFileInformation::Song;
|
||||||
if (const auto image = std::get_if<Image>(
|
if (const auto image = std::get_if<Image>(
|
||||||
&file.information->media)) {
|
&file.information->media)) {
|
||||||
|
Assert(!image->data.isNull());
|
||||||
if (ValidPhotoForAlbum(*image, file.information->filemime)) {
|
if (ValidPhotoForAlbum(*image, file.information->filemime)) {
|
||||||
UpdateImageDetails(file, previewWidth);
|
UpdateImageDetails(file, previewWidth);
|
||||||
file.type = PreparedFile::Type::Photo;
|
file.type = PreparedFile::Type::Photo;
|
||||||
|
@ -317,14 +322,18 @@ void UpdateImageDetails(PreparedFile &file, int previewWidth) {
|
||||||
if (!image) {
|
if (!image) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto &preview = image->modifications
|
Assert(!image->data.isNull());
|
||||||
|
auto preview = image->modifications
|
||||||
? Editor::ImageModified(image->data, image->modifications)
|
? Editor::ImageModified(image->data, image->modifications)
|
||||||
: image->data;
|
: image->data;
|
||||||
|
Assert(!preview.isNull());
|
||||||
file.shownDimensions = PrepareShownDimensions(preview);
|
file.shownDimensions = PrepareShownDimensions(preview);
|
||||||
file.preview = Images::prepareOpaque(preview.scaledToWidth(
|
const auto scaled = preview.scaledToWidth(
|
||||||
std::min(previewWidth, style::ConvertScale(preview.width()))
|
(std::min(previewWidth, style::ConvertScale(preview.width()))
|
||||||
* cIntRetinaFactor(),
|
* cIntRetinaFactor()),
|
||||||
Qt::SmoothTransformation));
|
Qt::SmoothTransformation);
|
||||||
|
Assert(!scaled.isNull());
|
||||||
|
file.preview = Images::prepareOpaque(scaled);
|
||||||
Assert(!file.preview.isNull());
|
Assert(!file.preview.isNull());
|
||||||
file.preview.setDevicePixelRatio(cRetinaFactor());
|
file.preview.setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue