From e9ead74ec4169d483de0b711986b5b560bbb730a Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Thu, 21 Jan 2016 17:04:38 +0100 Subject: Fixes for the mapviewer QtLocation example Currently identified problems with this example are: - the map element loses focus upon provider switch, or opening some other page (geocoding page, for example) - caused by changes in the StackView. Solved by forcing the focus upon map change - selecting minimap causes segfault - caused by dereferencing a null pointer (m_flick.m_animation) in qquickgeomapgesturearea.cpp - occasional (random) crashes with "QVector index out of bound" error - the menus show up on the wrong screen most of the time if the window spans multiple screens (but this is a broader qtquick problem) This patch fixes the first two issues Task-number: QTBUG-50519 Change-Id: Ic6b4a35e62e4651bd8003f47fade45f44a99d81c Reviewed-by: Alex Blasche --- examples/location/mapviewer/mapviewer.qml | 34 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'examples/location/mapviewer/mapviewer.qml') diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml index bcc2c919..2cb4e0d0 100644 --- a/examples/location/mapviewer/mapviewer.qml +++ b/examples/location/mapviewer/mapviewer.qml @@ -63,26 +63,41 @@ ApplicationWindow { var plugin if (parameters && parameters.length>0) - plugin = Qt.createQmlObject ('import QtLocation 5.3; Plugin{ name:"' + provider + '"; parameters: appWindow.parameters}', appWindow) + plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin{ name:"' + provider + '"; parameters: appWindow.parameters}', appWindow) else - plugin = Qt.createQmlObject ('import QtLocation 5.3; Plugin{ name:"' + provider + '"}', appWindow) + plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin{ name:"' + provider + '"}', appWindow) + if (minimap) { + minimap.destroy() + minimap = null + } + + var zoomLevel = null + var center = null if (map) { + zoomLevel = map.zoomLevel + center = map.center map.destroy() - minimap = null } map = mapComponent.createObject(page); map.plugin = plugin; - map.zoomLevel = (map.maximumZoomLevel - map.minimumZoomLevel)/2 + if (zoomLevel != null) { + map.zoomLevel = zoomLevel + map.center = center + } else { + map.zoomLevel = (map.maximumZoomLevel - map.minimumZoomLevel)/2 + } + + map.forceActiveFocus() } function getPlugins() { - var plugin = Qt.createQmlObject ('import QtLocation 5.3; Plugin {}', appWindow) + var plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin {}', appWindow) var myArray = new Array() for (var i = 0; i