Prevent Canceled FileChooser from calling print
ClosedPublic

Authored by rizzitello on Nov 23 2018, 5:29 AM.

Details

Summary

Changes from: https://phabricator.kde.org/R231:f72448828270d266acf4fbde69d09bc648337b7f Create an error dialog if the print function is called with empty filename. This checks that the dialog was accepted before sending the filename to the print function preventing the error message from showing.

Diff Detail

Branch
removeNoFileWarning
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 5327
Build 5345: arc lint + arc unit
rizzitello requested review of this revision.Nov 23 2018, 5:29 AM
rizzitello created this revision.
rizzitello edited the summary of this revision. (Show Details)Nov 23 2018, 5:30 AM
rizzitello added a project: Atelier.
rizzitello added a subscriber: Atelier.
patrickelectric requested changes to this revision.Nov 23 2018, 9:48 AM
patrickelectric added inline comments.
src/mainwindow.cpp
170–171

Why is this necessary ?

This revision now requires changes to proceed.Nov 23 2018, 9:48 AM
rizzitello marked an inline comment as done.Nov 23 2018, 11:17 AM
rizzitello added inline comments.
src/mainwindow.cpp
170–171

There is a check in print that will make an error dialog if print is called with an empty file . So by checking here we prevent this if the user hits cancel.

rizzitello updated this revision to Diff 46078.Nov 23 2018, 2:48 PM
rizzitello marked an inline comment as done.
  • rebase
rizzitello set the repository for this revision to R231 Atelier.Nov 23 2018, 2:56 PM
rizzitello edited the summary of this revision. (Show Details)Nov 23 2018, 2:58 PM
tcanabrava accepted this revision.Nov 23 2018, 3:04 PM
rizzitello edited the summary of this revision. (Show Details)Nov 23 2018, 3:23 PM
src/mainwindow.cpp
170–171
int result = dialog.exec();
if (result == QDialog::Rejected) {
    return;
}
if (result == QDialog::Accepted) {
    file = dialog.choosenFile();
}

Why not like this ?

int result = dialog.exec();
if (result != QDialog::Accepted) {
    return;
}
file = dialog.choosenFile();
  • Patricks suggestion
rizzitello marked an inline comment as done.Nov 24 2018, 12:14 AM
patrickelectric requested changes to this revision.Nov 24 2018, 3:48 PM
patrickelectric added inline comments.
src/mainwindow.cpp
168–169

!= accept makes more senses if new or a undefined behaviour happens,.

This revision now requires changes to proceed.Nov 24 2018, 3:48 PM
rizzitello updated this revision to Diff 46147.Nov 24 2018, 6:04 PM
  • patrick' suggestion to use != Accepted
rizzitello marked 2 inline comments as done.Nov 24 2018, 6:04 PM
patrickelectric accepted this revision.Nov 24 2018, 8:36 PM
This revision is now accepted and ready to land.Nov 24 2018, 8:36 PM
rizzitello closed this revision.Nov 25 2018, 12:13 AM