aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/scenegraph_lancelot
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2019-09-06 16:13:30 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2019-09-13 09:43:07 +0200
commit144193549a3a47ea3ade74289e3adc55c2bd65e6 (patch)
tree8c533bdcbc544bc08adbc816a3f14f8c388471bf /tests/manual/scenegraph_lancelot
parent04d92f9f9c16ace63a33ee18756ab8d40a1c1a66 (diff)
lancelot graphics test: Fix screengrabs being distorted on Windows
The grabbing process transports the image data to the main process over the stdout stream. Windows by default applies LF->CRLF conversion on that stream. Avoid by setting the binary mode flag on it. Change-Id: Ieec0911e24e21c111caeb35e35259833e1fdd639 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests/manual/scenegraph_lancelot')
-rw-r--r--tests/manual/scenegraph_lancelot/scenegrabber/main.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp
index 6da0799bbc..23c678380c 100644
--- a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp
+++ b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp
@@ -36,6 +36,11 @@
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
+#ifdef Q_OS_WIN
+# include <fcntl.h>
+# include <io.h>
+#endif // Q_OS_WIN
+
// Timeout values:
// A valid screen grab requires the scene to not change
@@ -101,6 +106,10 @@ private slots:
#endif
if (ofile == "-") { // Write to stdout
QFile of;
+#ifdef Q_OS_WIN
+ // Make sure write to stdout doesn't do LF->CRLF
+ _setmode(_fileno(stdout), _O_BINARY);
+#endif // Q_OS_WIN
if (!of.open(1, QIODevice::WriteOnly) || !lastGrab.save(&of, "ppm")) {
qWarning() << "Error: failed to write grabbed image to stdout.";
QGuiApplication::exit(2);