Fix Wayland image upload crash if confirmation dialog is enabled (#5314)

This commit is contained in:
pajlada
2024-04-12 23:48:08 +02:00
committed by GitHub
parent 1ca77a1e84
commit f4e950ea0b
4 changed files with 111 additions and 65 deletions
+17 -3
View File
@@ -380,12 +380,26 @@ Split::Split(QWidget *parent)
// this connection can be ignored since the SplitInput is owned by this Split
std::ignore = this->input_->ui_.textEdit->imagePasted.connect(
[this](const QMimeData *source) {
[this](const QMimeData *original) {
if (!getSettings()->imageUploaderEnabled)
{
return;
}
auto channel = this->getChannel();
auto *imageUploader = getIApp()->getImageUploader();
auto [images, imageProcessError] =
imageUploader->getImages(original);
if (images.empty())
{
channel->addMessage(makeSystemMessage(
QString(
"An error occurred trying to process your image: %1")
.arg(imageProcessError)));
return;
}
if (getSettings()->askOnImageUpload.getValue())
{
QMessageBox msgBox(this->window());
@@ -427,9 +441,9 @@ Split::Split(QWidget *parent)
return;
}
}
QPointer<ResizingTextEdit> edit = this->input_->ui_.textEdit;
getIApp()->getImageUploader()->upload(source, this->getChannel(),
edit);
imageUploader->upload(std::move(images), channel, edit);
});
getSettings()->imageUploaderEnabled.connect(