Fix drag-n-drop images from Firefox.

Commit a1b53c660e introduced a regression which caused images that
were shown for sending confirmation as a file path + image not being
passed to FileLoadTask in _image field, they were passed in the
_information field instead. They were not sent in case the file path
was not existing at the moment of processing. If the file path does
not exist anymore read the image from _information and send it.
This commit is contained in:
John Preston 2017-03-18 12:44:31 +03:00
parent 16fa56de48
commit 18151359f3
1 changed files with 23 additions and 16 deletions

View File

@ -381,26 +381,33 @@ void FileLoadTask::process() {
filename = filedialogDefaultName(qsl("file"), ext, QString(), true);
}
}
} else if (!fullimage.isNull() && fullimage.width() > 0) {
if (_type == SendMediaType::Photo) {
if (ValidateThumbDimensions(fullimage.width(), fullimage.height())) {
filesize = -1; // Fill later.
filemime = mimeTypeForName("image/jpeg").name();
filename = filedialogDefaultName(qsl("image"), qsl(".jpg"), QString(), true);
} else {
_type = SendMediaType::File;
} else {
if (_information) {
if (auto image = base::get_if<FileLoadTask::Image>(&_information->media)) {
fullimage = base::take(image->data);
}
}
if (_type == SendMediaType::File) {
filemime = mimeTypeForName("image/png").name();
filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
{
QBuffer buffer(&_content);
fullimage.save(&buffer, "PNG");
if (!fullimage.isNull() && fullimage.width() > 0) {
if (_type == SendMediaType::Photo) {
if (ValidateThumbDimensions(fullimage.width(), fullimage.height())) {
filesize = -1; // Fill later.
filemime = mimeTypeForName("image/jpeg").name();
filename = filedialogDefaultName(qsl("image"), qsl(".jpg"), QString(), true);
} else {
_type = SendMediaType::File;
}
}
filesize = _content.size();
if (_type == SendMediaType::File) {
filemime = mimeTypeForName("image/png").name();
filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
{
QBuffer buffer(&_content);
fullimage.save(&buffer, "PNG");
}
filesize = _content.size();
}
fullimage = Images::prepareOpaque(std::move(fullimage));
}
fullimage = Images::prepareOpaque(std::move(fullimage));
}
_result->filesize = (int32)qMin(filesize, qint64(INT_MAX));