Commit c9f20bed authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make some file formats return KisImportExportFilter::UserCancelled when their...

Make some file formats return KisImportExportFilter::UserCancelled when their options dialogs are cancelled

Summary:
The file formats affected by this patch are: r16 heightmap/r8 heightmap/JPEG-2000/JPEG/PNG/PPM/PGM/PBM

These formats return KisImportExportFilter::OK rather than KisImportExportFilter::UserCancelled when their import/export options dialog is cancelled.

This leads to buggy behaviour that can be reproduced using either set of the following steps:
CASE 1
    * Create a new document and modify it
    * Close the document and opt to save it as one of the affected formats
    * Cancel when the export options appear
    * (The document closes without saving)
CASE 2
    * Open a heightmap
    * Cancel when the import options appear
    * (Krita crashes)

I've also modified kis_png_export.cc so that it sets up the Cancel/OK buttons explicitly instead of relying on getting them by default from KDialog.

Reviewers: #krita:_stable, rempt

Reviewed By: #krita:_stable, rempt

Subscribers: rempt

Differential Revision: https://phabricator.kde.org/D548

Patch by Nicholas LaPointe, thanks!
parent 8e509f67
......@@ -113,7 +113,7 @@ KisImportExportFilter::ConversionStatus KisHeightMapExport::convert(const QByteA
if (!m_chain->manager()->getBatchMode()) {
if (kdb->exec() == QDialog::Rejected) {
return KisImportExportFilter::OK; // FIXME Cancel doesn't exist :(
return KisImportExportFilter::UserCancelled;
}
}
else {
......
......@@ -145,7 +145,7 @@ KisImportExportFilter::ConversionStatus KisHeightMapImport::convert(const QByteA
if (!m_chain->manager()->getBatchMode()) {
if (kdb->exec() == QDialog::Rejected) {
return KisImportExportFilter::OK; // FIXME Cancel doesn't exist :(
return KisImportExportFilter::UserCancelled;
}
}
......
......@@ -92,7 +92,7 @@ KisImportExportFilter::ConversionStatus jp2Export::convert(const QByteArray& fro
if (!m_chain->manager()->getBatchMode()) {
if (kdb->exec() == QDialog::Rejected) {
return KisImportExportFilter::OK; // FIXME Cancel doesn't exist :(
return KisImportExportFilter::UserCancelled;
}
}
else {
......
......@@ -130,7 +130,7 @@ KisImportExportFilter::ConversionStatus KisJPEGExport::convert(const QByteArray&
if (!m_chain->manager()->getBatchMode()) {
if (kdb->exec() == QDialog::Rejected) {
return KisImportExportFilter::OK; // FIXME Cancel doesn't exist :(
return KisImportExportFilter::UserCancelled;
}
}
else {
......
......@@ -90,6 +90,7 @@ KisImportExportFilter::ConversionStatus KisPNGExport::convert(const QByteArray&
KoDialog* kdb = new KoDialog(0);
kdb->setCaption(i18n("PNG Export Options"));
kdb->setModal(false);
kdb->setButtons(KDialog::Ok | KDialog::Cancel);
KisImageWSP image = input->image();
qApp->processEvents(); // For vector layers to be updated
......@@ -173,7 +174,7 @@ KisImportExportFilter::ConversionStatus KisPNGExport::convert(const QByteArray&
if (hasVisibleWidgets()) {
if (!m_chain->manager()->getBatchMode()) {
if (kdb->exec() == QDialog::Rejected) {
return KisImportExportFilter::OK; // FIXME Cancel doesn't exist :(
return KisImportExportFilter::UserCancelled;
}
}
}
......
......@@ -171,7 +171,7 @@ KisImportExportFilter::ConversionStatus KisPPMExport::convert(const QByteArray&
if (!m_chain->manager()->getBatchMode()) {
if (kdb->exec() == QDialog::Rejected) {
return KisImportExportFilter::OK; // FIXME Cancel doesn't exist :(
return KisImportExportFilter::UserCancelled;
}
}
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment