Crash when using events when tile loading has finished

Hello,
our Software runs on OpenText / Gupta Team Developer 6.3 and we have a reproduceable crash when using the mapwindow ocx.
I was able to track it down to these cuircamtances:
Everytime when a zoom requires a tile loading or the map window is created the first time the crash appears as soon as all tiles are loaded.
The only time this crash does not appear is when all tiles are in the cache - therefore a test application with the most basic form window and only the mapwindow ocx will have this behaviour:

  • 1st execution -> map loaded for Germany, after all tiles are loaded, crash
  • 2nd execution -> map loaded for Germany, crash when zooming in for example to Berlin after loading of tiles
  • 3rd execution -> map loaded, zooming in to the same point in Berlin with the same zoom is fine, back to germany is fine, zooming in on Munich -> crash after tile loading

This happens everytime we catch any kind of event of the MapWindow ocx. If i dont catch any events it works fine.
Of the events we only use:

  • MouseMove
  • SelectBoxFinal

To see where the error comes from I´ve added additional events for TilesLoaded and ExtentsChanged.
The problem seems to be somewhere near the TilesLoaded event - the event fires correct when tiles are loaded from the cache ( RAM or disk doesnt matter ) and it does not fire when the loading of uncached tiles has finished. Right where you expect it to fire it crashes.

We are using the 5.1.1 Win32 Build VS 2017.
The problem seems to be familiar with the issue #128 from GitHub:


and especially #59

Here are the codeline for my testapp regarding the MapWindow ocx after Form Window Creation:

Call global_settings.StartLogTileRequests( ‘c:\temp\tiles\log.txt’, FALSE, nValues0 )
Call axMap.GetKnownExtents( MapWinGIS_tkKnownExtents_keGermany, exGermany )
Call axMap.PropGetTiles( Tiles )
Call Tiles.PropSetDiskCacheFilename( ‘c:\temp\mapwingis.cache’ )
Call Tiles.PropSetDoCaching( MapWinGIS_tkCacheType_Disk, FALSE )
Call Tiles.PropSetDoCaching( MapWinGIS_tkCacheType_RAM, FALSE )

Call axMap.LockWindow( MapWinGIS_tkLockMode_lmLock )
Call axMap.ZoomToMaxExtents()
Call axMap.LockWindow( MapWinGIS_tkLockMode_lmUnlock )

Call axMap.Redraw()

The Properties for the controls are set to use OpenStreetMap und Google Mercartor.

Some more tests revealed that the crash does not occur when the last two line ( LockWindow with Unload and Redraw ) are removed. But as soon as the next redraw is called the crash is there again.

After more testing and some experiments we we´re able to confirm the function in which the crash occures.
Its the function FireTilesLoaded - although we´re sure it´s not the root of the problem.
After commenting the FireEvent call everything runs without anymore crashes ( we modified the source and build a test ocx ).

Is there any way to supress the this FireEvent for TilesLoaded ?
We dont need it and a property much like SendMouseDown(…) or SendMouseMove(…) would be a welcomed workaround.

Hello @Stephan

I’m sorry I missed your initial post (1 month ago). Looking things over, I wonder if there may an issue with the string ‘key’ that is passed as a parameter of the event, that it may not be in the right format. I will try to look into this.

In the mean time, if you want to try a shot-in-the-dark, try changing line ~643 of Map.h to the following:

FireEvent(eventidTilesLoaded, EVENT_PARAM(VTS_BOOL VTS_BSTR VTS_BOOL), isSnapShot, A2BSTR(key), isFromCache);

wrapping the ‘key’ string in a macro (A2BSTR) that formally converts the null-terminated string into a BSTR, which is what COM should be passing as a parameter. It may well be that it is already being converted down in the bowels of the Microsoft COleControl code. But just in case it’s not, I wonder if that’s what is tripping up your code.

I’m not necessarily opposed to suppressing the event, but it would be nice to know why the event causes problems.

Regards,
Jerry.

I´ve forwared your reply to our developer - we´ll keep you updated on the progress.

We´ve tested the call with the parameters:

FireEvent(eventidTilesLoaded, EVENT_PARAM(VTS_BOOL VTS_BSTR VTS_BOOL), isSnapShot, A2BSTR(key), isFromCache);

But it still crashes - I´ve reactivated the version without the FireEvent and the crash is gone.

Btw:
The Message itself is a nice to have for us but not a nessarity - still it would be nice if the control would have some kind of built-in / out of the box progress bar which indicates the progress of the tile loading.

Hello @Stephan

I will have to do more review of the Event…

Regarding the progress, have you looked at the ICallback interface, which provides a Progress callback that you can hook through the GlobalSettings.ApplicationCallback property. The callback then applies to many of the various MWG classes, including the Tiles class, and you can tell who’s posting the Progress by checking the KeyOfSender value. I hope that helps.

Regards,
Jerry.

I´m sorry for the late answer.
Unfortunalty there is no way to integrate an ActiveX Callback on Team Developer that I know of.
I cant get an instance from the ApplicationCallback property but I cant override the functions :frowning: