summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Zotti <Georg.Zotti@univie.ac.at>2023-03-18 19:25:12 +0100
committerGeorg Zotti <Georg.Zotti@univie.ac.at>2023-03-18 19:25:12 +0100
commit67d8bc6e97a2ef14258e5a8baa3d11a6c7de0d73 (patch)
tree66077c1ef07ae49417683b8728e8fc2b0ac42e2d
parent468ab9b2b8379442948cb70118cf3e640a0e7108 (diff)
Add a check for screenshot file format
-rw-r--r--src/scripting/StelMainScriptAPI.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/scripting/StelMainScriptAPI.cpp b/src/scripting/StelMainScriptAPI.cpp
index a1fbaeec54..a652166061 100644
--- a/src/scripting/StelMainScriptAPI.cpp
+++ b/src/scripting/StelMainScriptAPI.cpp
@@ -342,11 +342,18 @@ QStringList StelMainScriptAPI::getAllTimezoneNames()
void StelMainScriptAPI::screenshot(const QString& prefix, bool invert, const QString& dir, const bool overwrite, const QString &format)
{
- bool oldInvertSetting = StelMainView::getInstance().getFlagInvertScreenShotColors();
- QString oldFormat=StelMainView::getInstance().getScreenshotFormat();
- StelMainView::getInstance().setFlagInvertScreenShotColors(invert);
+ const bool oldInvertSetting = StelMainView::getInstance().getFlagInvertScreenShotColors();
+ const QString oldFormat=StelMainView::getInstance().getScreenshotFormat();
if ((format.length()>0) && (format.length()<=4))
StelMainView::getInstance().setScreenshotFormat(format);
+ // Check requested against set image format.
+ if (StelMainView::getInstance().getScreenshotFormat() != format)
+ {
+ qWarning() << "Screenshot format" << format << "not supported. Not saving screenshot.";
+ return;
+ }
+
+ StelMainView::getInstance().setFlagInvertScreenShotColors(invert);
StelMainView::getInstance().setFlagOverwriteScreenShots(overwrite);
StelMainView::getInstance().saveScreenShot(prefix, dir, overwrite);
StelMainView::getInstance().setFlagInvertScreenShotColors(oldInvertSetting);