MapXL / route-me

Automatically exported from code.google.com/p/route-me
0 stars 0 forks source link

<CALayerArray: 0x1771d0> was mutated while being enumerated #115

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
How to solve this specific problem? It happens when i try to add path into 
overlay

*** Terminating app due to uncaught exception 'NSGenericException', reason: 
'*** Collection 
<CALayerArray: 0x1771d0> was mutated while being enumerated.'

Original issue reported on code.google.com by chai.hua...@gmail.com on 12 Aug 2009 at 3:50

GoogleCodeExporter commented 8 years ago
Please provide enough source code to reproduce the error.

Original comment by halmuel...@gmail.com on 12 Aug 2009 at 4:05

GoogleCodeExporter commented 8 years ago
I think i got the point from other website on the route-me mailing list. It 
mentioned the problem is caused by 
tring to change the mutable structure when it is just read by another thread. 
Copy it to another array for 
editing or lock it may be the proper way. I just want to know how to proper 
lock it because it fails when i try 
to lock it.

My code is listed below.
    RMLayerSet *overlay = [[mapView contents] overlay];
    NSArray *sublayers = [overlay sublayers];   

    @synchronized(sublayers){
    RMPath *path = [[RMPath alloc] initForMap:self.mapView];
    path.drawingMode = kCGPathStroke;   
    path.lineColor = thepath.lineColor;
    path.lineWidth = 10;

    if(thepath.polyColor != nil)
    {
        path.fillColor = thepath.polyColor;
        path.drawingMode = kCGPathFillStroke;
        path.lineWidth = 25;
    }

    NSArray *crs = [thepath coordinates];
    CLLocationCoordinate2D coord;
    for(NSString *scoord in crs)
    {   
        NSString *str = [scoord stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        NSArray *split = [str componentsSeparatedByString:@","];

        if([split count] >= 2)
        {
            coord.longitude = [[split objectAtIndex:0] doubleValue];
            coord.latitude = [[split objectAtIndex:1] doubleValue];
            [path addLineToLatLong:coord];
        }
    }
    [[[self.mapView contents] overlay] addSublayer:path];
    [path release];
    }

Original comment by chai.hua...@gmail.com on 12 Aug 2009 at 8:08

GoogleCodeExporter commented 8 years ago
I think i got the point from other website on the route-me mailing list. It 
mentioned the problem is caused by 
tring to change the mutable structure when it is just read by another thread. 
Copy it to another array for 
editing or lock it may be the proper way. I just want to know how to proper 
lock it because it fails when i try 
to lock it.

My code is listed below.
    RMLayerSet *overlay = [[mapView contents] overlay];
    NSArray *sublayers = [overlay sublayers];   

    @synchronized(sublayers){
    RMPath *path = [[RMPath alloc] initForMap:self.mapView];
    path.drawingMode = kCGPathStroke;   
    path.lineColor = thepath.lineColor;
    path.lineWidth = 10;

    if(thepath.polyColor != nil)
    {
        path.fillColor = thepath.polyColor;
        path.drawingMode = kCGPathFillStroke;
        path.lineWidth = 25;
    }

    NSArray *crs = [thepath coordinates];
    CLLocationCoordinate2D coord;
    for(NSString *scoord in crs)
    {   
        NSString *str = [scoord stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        NSArray *split = [str componentsSeparatedByString:@","];

        if([split count] >= 2)
        {
            coord.longitude = [[split objectAtIndex:0] doubleValue];
            coord.latitude = [[split objectAtIndex:1] doubleValue];
            [path addLineToLatLong:coord];
        }
    }
    [[[self.mapView contents] overlay] addSublayer:path];
    [path release];
    }

Original comment by chai.hua...@gmail.com on 12 Aug 2009 at 8:08

GoogleCodeExporter commented 8 years ago
I think i got the point from other website on the route-me mailing list. It 
mentioned the problem is caused by 
tring to change the mutable structure when it is just read by another thread. 
Copy it to another array for 
editing or lock it may be the proper way. I just want to know how to proper 
lock it because it fails when i try 
to lock it.

My code is listed below.
    RMLayerSet *overlay = [[mapView contents] overlay];
    NSArray *sublayers = [overlay sublayers];   

    @synchronized(sublayers){
    RMPath *path = [[RMPath alloc] initForMap:self.mapView];
    path.drawingMode = kCGPathStroke;   
    path.lineColor = thepath.lineColor;
    path.lineWidth = 10;

    if(thepath.polyColor != nil)
    {
        path.fillColor = thepath.polyColor;
        path.drawingMode = kCGPathFillStroke;
        path.lineWidth = 25;
    }

    NSArray *crs = [thepath coordinates];
    CLLocationCoordinate2D coord;
    for(NSString *scoord in crs)
    {   
        NSString *str = [scoord stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        NSArray *split = [str componentsSeparatedByString:@","];

        if([split count] >= 2)
        {
            coord.longitude = [[split objectAtIndex:0] doubleValue];
            coord.latitude = [[split objectAtIndex:1] doubleValue];
            [path addLineToLatLong:coord];
        }
    }
    [[[self.mapView contents] overlay] addSublayer:path];
    [path release];
    }

Original comment by chai.hua...@gmail.com on 12 Aug 2009 at 8:09

GoogleCodeExporter commented 8 years ago
'*** Collection <CALayerArray: 0x7bbc1800> was mutated while being enumerated.'

Original comment by ankit.ma...@gmail.com on 8 Dec 2014 at 9:55