Avoid QObject::connect null warning

This commit is contained in:
Nyall Dawson 2018-11-19 14:43:58 +10:00
parent 34c217cd46
commit a8ecc683b7

View File

@ -172,9 +172,11 @@ QgsMapCanvas::QgsMapCanvas( QWidget *parent )
moveCanvasContents( true );
// keep device pixel ratio up to date on screen or resolution change
connect( window()->windowHandle(), &QWindow::screenChanged, this, [ = ]( QScreen * ) {mSettings.setDevicePixelRatio( devicePixelRatio() );} );
if ( window()->windowHandle() )
{
connect( window()->windowHandle(), &QWindow::screenChanged, this, [ = ]( QScreen * ) {mSettings.setDevicePixelRatio( devicePixelRatio() );} );
connect( window()->windowHandle()->screen(), &QScreen::physicalDotsPerInchChanged, this, [ = ]( qreal ) {mSettings.setDevicePixelRatio( devicePixelRatio() );} );
}
connect( &mMapUpdateTimer, &QTimer::timeout, this, &QgsMapCanvas::mapUpdateTimeout );
mMapUpdateTimer.setInterval( 250 );