Skip to content

Commit 3d5bc45

Browse files
dl3sdodg0yt
authored andcommitted
PrintWidget: Show warning if world file export fails
1 parent e98392b commit 3d5bc45

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/gui/print_widget.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,12 +1322,15 @@ void PrintWidget::exportToImage()
13221322
{
13231323
main_window->showStatusBarMessage(tr("Exported successfully to %1").arg(path), 4000);
13241324
if (world_file_check->isChecked())
1325-
exportWorldFile(path); /// \todo Handle errors
1325+
{
1326+
if (!exportWorldFile(path))
1327+
QMessageBox::warning(this, tr("Error"), tr("Failed to save the world file."));
1328+
}
13261329
emit finished(0);
13271330
}
13281331
}
13291332

1330-
void PrintWidget::exportWorldFile(const QString& path) const
1333+
bool PrintWidget::exportWorldFile(const QString& path) const
13311334
{
13321335
const auto& georef = map->getGeoreferencing();
13331336
const auto& mm_to_world = georef.mapToProjected();
@@ -1339,7 +1342,7 @@ void PrintWidget::exportWorldFile(const QString& path) const
13391342
const auto top_left = georef.toProjectedCoords(MapCoord{map_printer->getPrintArea().topLeft()});
13401343
const QTransform pixel_to_world(xscale, yskew, 0, xskew, yscale, 0, top_left.x(), top_left.y());
13411344
const WorldFile world_file(pixel_to_world);
1342-
world_file.save(WorldFile::pathForImage(path));
1345+
return world_file.save(WorldFile::pathForImage(path));
13431346
}
13441347

13451348
void PrintWidget::exportToPdf()

src/gui/print_widget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ protected slots:
263263
void exportToImage();
264264

265265
/** Export a world file */
266-
void exportWorldFile(const QString& path) const;
266+
bool exportWorldFile(const QString& path) const;
267267

268268
/** Exports to a PDF file. */
269269
void exportToPdf();

0 commit comments

Comments
 (0)