From 739c07bc37886d7ee4c63f80a290286fc8cf8340 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 26 May 2015 14:35:08 -0700 Subject: [PATCH] No MainWindow possible when unit testing --- src/QmlControls/ScreenTools.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/QmlControls/ScreenTools.cc b/src/QmlControls/ScreenTools.cc index 77c0ccb19..c7d59f4cf 100644 --- a/src/QmlControls/ScreenTools.cc +++ b/src/QmlControls/ScreenTools.cc @@ -36,9 +36,14 @@ const double ScreenTools::_largeFontPointSize = 20; ScreenTools::ScreenTools() { - connect(MainWindow::instance(), &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas); - connect(MainWindow::instance(), &MainWindow::pixelSizeChanged, this, &ScreenTools::_updatePixelSize); - connect(MainWindow::instance(), &MainWindow::fontSizeChanged, this, &ScreenTools::_updateFontSize); + MainWindow* mainWindow = MainWindow::instance(); + + // Unit tests can run Qml without MainWindow + if (mainWindow) { + connect(mainWindow, &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas); + connect(mainWindow, &MainWindow::pixelSizeChanged, this, &ScreenTools::_updatePixelSize); + connect(mainWindow, &MainWindow::fontSizeChanged, this, &ScreenTools::_updateFontSize); + } } qreal ScreenTools::adjustFontPointSize(qreal pointSize) -- 2.22.0