mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +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 {
|
||||
|
||||
QImage ImageModified(QImage image, const PhotoModifications &mods) {
|
||||
Expects(!image.isNull());
|
||||
|
||||
if (!mods) {
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ bool HasExtensionFrom(const QString &file, const QStringList &extensions) {
|
|||
bool ValidPhotoForAlbum(
|
||||
const Image &image,
|
||||
const QString &mime) {
|
||||
Expects(!image.data.isNull());
|
||||
|
||||
if (image.animated
|
||||
|| Core::IsMimeSticker(mime)
|
||||
|| (!mime.isEmpty() && !mime.startsWith(u"image/"))) {
|
||||
|
@ -228,6 +230,8 @@ PreparedList PrepareMediaFromImage(
|
|||
QImage &&image,
|
||||
QByteArray &&content,
|
||||
int previewWidth) {
|
||||
Expects(!image.isNull());
|
||||
|
||||
auto result = PreparedList();
|
||||
auto file = PreparedFile(QString());
|
||||
file.content = content;
|
||||
|
@ -288,6 +292,7 @@ void PrepareDetails(PreparedFile &file, int previewWidth) {
|
|||
using Song = PreparedFileInformation::Song;
|
||||
if (const auto image = std::get_if<Image>(
|
||||
&file.information->media)) {
|
||||
Assert(!image->data.isNull());
|
||||
if (ValidPhotoForAlbum(*image, file.information->filemime)) {
|
||||
UpdateImageDetails(file, previewWidth);
|
||||
file.type = PreparedFile::Type::Photo;
|
||||
|
@ -317,14 +322,18 @@ void UpdateImageDetails(PreparedFile &file, int previewWidth) {
|
|||
if (!image) {
|
||||
return;
|
||||
}
|
||||
const auto &preview = image->modifications
|
||||
Assert(!image->data.isNull());
|
||||
auto preview = image->modifications
|
||||
? Editor::ImageModified(image->data, image->modifications)
|
||||
: image->data;
|
||||
Assert(!preview.isNull());
|
||||
file.shownDimensions = PrepareShownDimensions(preview);
|
||||
file.preview = Images::prepareOpaque(preview.scaledToWidth(
|
||||
std::min(previewWidth, style::ConvertScale(preview.width()))
|
||||
* cIntRetinaFactor(),
|
||||
Qt::SmoothTransformation));
|
||||
const auto scaled = preview.scaledToWidth(
|
||||
(std::min(previewWidth, style::ConvertScale(preview.width()))
|
||||
* cIntRetinaFactor()),
|
||||
Qt::SmoothTransformation);
|
||||
Assert(!scaled.isNull());
|
||||
file.preview = Images::prepareOpaque(scaled);
|
||||
Assert(!file.preview.isNull());
|
||||
file.preview.setDevicePixelRatio(cRetinaFactor());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue