Merge pull request #25 from incanus/better_tile_notifications
better tile notifications on main queue & with tile reference hashes
Showing
2 changed files
with
20 additions
and
4 deletions
@@ -61,7 +61,10 @@ | @@ -61,7 +61,10 @@ | ||
61 | if (image) | 61 | if (image) |
62 | return image; | 62 | return image; |
63 | 63 | ||
64 | - [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:nil]; | 64 | + dispatch_async(dispatch_get_main_queue(), ^(void) |
65 | + { | ||
66 | + [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]]; | ||
67 | + }); | ||
65 | 68 | ||
66 | [tileCache retain]; | 69 | [tileCache retain]; |
67 | 70 | ||
@@ -93,12 +96,12 @@ | @@ -93,12 +96,12 @@ | ||
93 | 96 | ||
94 | if (tileData) | 97 | if (tileData) |
95 | { | 98 | { |
96 | - dispatch_sync(dispatch_get_main_queue(), ^(void) | 99 | + @synchronized(self) |
97 | { | 100 | { |
98 | // safely put into collection array in proper order | 101 | // safely put into collection array in proper order |
99 | // | 102 | // |
100 | [tilesData replaceObjectAtIndex:u withObject:tileData]; | 103 | [tilesData replaceObjectAtIndex:u withObject:tileData]; |
101 | - }); | 104 | + }; |
102 | } | 105 | } |
103 | }); | 106 | }); |
104 | } | 107 | } |
@@ -135,7 +138,10 @@ | @@ -135,7 +138,10 @@ | ||
135 | 138 | ||
136 | [tileCache release]; | 139 | [tileCache release]; |
137 | 140 | ||
138 | - [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:nil]; | 141 | + dispatch_async(dispatch_get_main_queue(), ^(void) |
142 | + { | ||
143 | + [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]]; | ||
144 | + }); | ||
139 | 145 | ||
140 | if (!image) | 146 | if (!image) |
141 | return [RMTileImage errorTile]; | 147 | return [RMTileImage errorTile]; |
@@ -96,6 +96,11 @@ | @@ -96,6 +96,11 @@ | ||
96 | NSInteger x = tile.x; | 96 | NSInteger x = tile.x; |
97 | NSInteger y = pow(2, zoom) - tile.y - 1; | 97 | NSInteger y = pow(2, zoom) - tile.y - 1; |
98 | 98 | ||
99 | + dispatch_async(dispatch_get_main_queue(), ^(void) | ||
100 | + { | ||
101 | + [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]]; | ||
102 | + }); | ||
103 | + | ||
99 | __block UIImage *image; | 104 | __block UIImage *image; |
100 | 105 | ||
101 | [queue inDatabase:^(FMDatabase *db) | 106 | [queue inDatabase:^(FMDatabase *db) |
@@ -120,6 +125,11 @@ | @@ -120,6 +125,11 @@ | ||
120 | [results close]; | 125 | [results close]; |
121 | }]; | 126 | }]; |
122 | 127 | ||
128 | + dispatch_async(dispatch_get_main_queue(), ^(void) | ||
129 | + { | ||
130 | + [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]]; | ||
131 | + }); | ||
132 | + | ||
123 | return image; | 133 | return image; |
124 | } | 134 | } |
125 | 135 |
-
Please register or login to post a comment