Stopped working code in version 5.1.0

I’ve been using the answers in the forum implemented in the program dynamic labels for polylines (streets).
The compiled program works fine with MapWinGIS version 5.0.1, and this same file already refuses to work with version 5.1.
He began to understand what it is…

  1. In version 5.1, the function ShapeFile.Clip if there are no objects on the source layer throws an exception error - access violation.
    However, in version 5.0.1, this function returns null. It’s now a result failure… and program closes.
  2. In the previous version, MapWinGIS the result of ShapeFile.Clip I generated labels and they worked! Now just nothing happens.

Here is an example:

   var clipShape: IShape := CoShape.Create;
   clipShape := EzMap.Extents.ToShape;
   var sfClip: IShapefile := CoShapefile.Create;
   sfClip.CreateNewWithShapeID('', SHP_POLYGON);
   sfClip.GeoProjection := AxMap.GeoProjection.Clone;
   sfClip.EditAddShape(clipShape);
   ObjectsLayer := AxMap.Shapefile[LayerHandle];
   var sfClipResult: IShapefile;

   // here, an access violation if the layer 'ObjectsLayer' zooming and not contain objects on it at the moment in AxMap
   sfClipResult := ObjectsLayer.Clip(False, sfClip, False);
   
   //if everything works correctly, then it doesn't work Labels.Generate
   sfClipResult.Labels.Generate('[Label]', lpMiddleSegment, False);

What can be done, how to get around? Is it a bug or a new feature?

Hello @mainxt

I was able to duplicate the error. Indeed this is a bug introduced in the latest version, related to some Shapefile locking that was added. In this case, the resulting Shapefile is empty, and is therefore being closed and destroyed, but the Lock is not being released, resulting in the access violation.

I will have to have a discussion with @pmeems and @Mathijs.Dumon to review the options moving forward. If you can, you should stay with the previous version for the time being.

Regards.
Jerry.

Hello @jerryfaust

Well. Until remain on version of 5.0.1, i will wait for corrections… And not generated labels, too, for the same reason?

Hello again.

I’m sorry, I forgot to check that yesterday.

I just stepped through again to test the Labels, and yes, it is encountering another related bug. I will see if I can get a patch put together that at least addresses these two issues. Perhaps by this evening.

Regards.

1 Like

Ok. Thank you Jerry for attention. I we’ll wait…

@pmeems, I’ve commited two changes that address the issues encountered by @mainxt, in case you want to create a patch, or a temporary development build? If it would help, I can create an interim build.

I’ve pulled the changes of @jerryfaust and created a new installer.
It is available at my Google Drive
@mainxt Could you test this version and let me know if it is solving your problems.
If so I will issue a new version.

@pmeems Yes, this version fixes all of the above issues. Work correctly.
Thank you all very much.

Thanks for the feedback.