Changeset 253a6f2


Ignore:
Timestamp:
02/01/17 02:59:25 (4 weeks ago)
Author:
Martin Kolman <martin.kolman@…>
Branches:
master
Children:
3f08518
Parents:
e36e21f
git-author:
Martin Kolman <martin.kolman@…> (02/01/17 02:59:25)
git-committer:
Martin Kolman <martin.kolman@…> (02/01/17 02:59:25)
Message:

Possible fix for no tiles being shown at startup

Like like on some devices with a 1080p screen map tiles might not load, resulting with the map screen
being black and missing any tiles. So let's try to fix this by making sure the tile model update script is
first properly initialized before sending it messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/gui_modules/gui_qt5/qml/PinchMap.qml

    r83ca3f1 r253a6f2  
    177177    WorkerScript { 
    178178        id : updateTilesModelWorker 
     179        property bool workerInitialized: false 
     180        property var replayMessages : [] 
    179181        source : "workers/update_tiles_model.js" 
    180182        onMessage: { 
     
    202204        } 
    203205 
     206        Component.onCompleted: { 
     207            rWin.log.debug("Tile model worker script has been initialized.") 
     208            updateTilesModelWorker.workerInitialized = true 
     209            // Try to replay a messages that might have been 
     210            // stored due to worker script not being initialized yet. 
     211            // Ignoring such messages might result in no map tiles being shown. 
     212            if (replayMessages != []) { 
     213                rWin.log.debug("Replaying deferred messages to tile model worker script.") 
     214                for (var i=0; i<replayMessages.length; i++) { 
     215                    rWin.log.debug("Replaying message nr.: " + (i+1)) 
     216                    updateTilesModelWorker.sendMessage(replayMessages[i]) 
     217                } 
     218                replayMessages = [] 
     219            } 
     220        } 
    204221    } 
    205222 
     
    217234            tileRequestTimerPause = true 
    218235            // start the asynchronous tile model update 
    219             updateTilesModelWorker.sendMessage( 
    220                 { 
     236            if (updateTilesModelWorker.workerInitialized) { 
     237                updateTilesModelWorker.sendMessage( 
     238                    { 
     239                        cornerX : pinchmap.cornerTileX, 
     240                        cornerY : pinchmap.cornerTileY, 
     241                        tilesX : pinchmap.numTilesX, 
     242                        tilesY : pinchmap.numTilesY, 
     243                        tilesModel : pinchmap.tilesModel, 
     244                        shouldBeOnScreen : pinchmap.shouldBeOnScreen 
     245                    } 
     246                ) 
     247            } else { 
     248                rWin.log.debug("Worker script not yet initialized.") 
     249                updateTilesModelWorker.replayMessages.push({ 
    221250                    cornerX : pinchmap.cornerTileX, 
    222251                    cornerY : pinchmap.cornerTileY, 
     
    225254                    tilesModel : pinchmap.tilesModel, 
    226255                    shouldBeOnScreen : pinchmap.shouldBeOnScreen 
    227                 } 
    228             ) 
     256                }) 
     257            } 
    229258        } 
    230259    } 
Note: See TracChangeset for help on using the changeset viewer.