Printing: safer Template->Import|Export handling

Check if the file string is empty and return, else process it.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2015-07-28 11:26:41 +03:00
parent ccddcc3952
commit 01645d64b9

View file

@ -106,6 +106,8 @@ void PrintOptions::on_importButton_clicked()
{
QString filename = QFileDialog::getOpenFileName(this, tr("Import Template file"), "",
tr("HTML files (*.html)"));
if (filename.isEmpty())
return;
QFileInfo fileInfo(filename);
QFile::copy(filename, getSubsurfaceDataPath("printing_templates") + QDir::separator() + fileInfo.fileName());
printOptions->p_template = fileInfo.fileName();
@ -117,6 +119,8 @@ void PrintOptions::on_exportButton_clicked()
{
QString filename = QFileDialog::getSaveFileName(this, tr("Export Template files as"), "",
tr("HTML files (*.html)"));
if (filename.isEmpty())
return;
QFile::copy(getSubsurfaceDataPath("printing_templates") + QDir::separator() + getSelectedTemplate(), filename);
}