@@ -110,6 +110,11 @@ internal final class StyleSourceManager: StyleSourceManagerProtocol {
110110 let identifier = UUID ( )
111111 let item = DispatchWorkItem { [ weak self] in
112112 guard let self else { return }
113+ defer {
114+ self . mainQueue. async { [ weak self] in
115+ self ? . workItemTracker. removePartialUpdateCancelable ( for: sourceId, uuid: identifier)
116+ }
117+ }
113118 do {
114119 try handleExpected {
115120 return self . styleManager. addGeoJSONSourceFeatures ( forSourceId: sourceId,
@@ -120,9 +125,6 @@ internal final class StyleSourceManager: StyleSourceManagerProtocol {
120125 Log . error ( " Failed to add features for source with id: \( sourceId) , dataId: \( dataId ?? " " ) , error: \( error) " )
121126 }
122127 }
123- item. notify ( queue: . main) { [ weak self] in
124- self ? . workItemTracker. removePartialUpdateCancelable ( for: sourceId, uuid: identifier)
125- }
126128 workItemTracker. addPartialUpdateCancelable ( AnyCancelable ( item. cancel) , for: sourceId, uuid: identifier)
127129 backgroundQueue. async ( execute: item)
128130 }
@@ -167,6 +169,11 @@ internal final class StyleSourceManager: StyleSourceManagerProtocol {
167169 let identifier = UUID ( )
168170 let item = DispatchWorkItem { [ weak self] in
169171 guard let self else { return }
172+ defer {
173+ self . mainQueue. async { [ weak self] in
174+ self ? . workItemTracker. removePartialUpdateCancelable ( for: sourceId, uuid: identifier)
175+ }
176+ }
170177 do {
171178 try handleExpected {
172179 return self . styleManager. updateGeoJSONSourceFeatures ( forSourceId: sourceId,
@@ -177,9 +184,6 @@ internal final class StyleSourceManager: StyleSourceManagerProtocol {
177184 Log . error ( " Failed to update features for source with id: \( sourceId) , dataId: \( dataId ?? " " ) , error: \( error) " )
178185 }
179186 }
180- item. notify ( queue: . main) { [ weak self] in
181- self ? . workItemTracker. removePartialUpdateCancelable ( for: sourceId, uuid: identifier)
182- }
183187
184188 workItemTracker. addPartialUpdateCancelable ( AnyCancelable ( item. cancel) , for: sourceId, uuid: identifier)
185189 backgroundQueue. async ( execute: item)
@@ -189,6 +193,11 @@ internal final class StyleSourceManager: StyleSourceManagerProtocol {
189193 let identifier = UUID ( )
190194 let item = DispatchWorkItem { [ weak self] in
191195 guard let self else { return }
196+ defer {
197+ self . mainQueue. async { [ weak self] in
198+ self ? . workItemTracker. removePartialUpdateCancelable ( for: sourceId, uuid: identifier)
199+ }
200+ }
192201 do {
193202 try handleExpected {
194203 return self . styleManager. removeGeoJSONSourceFeatures ( forSourceId: sourceId,
@@ -199,9 +208,6 @@ internal final class StyleSourceManager: StyleSourceManagerProtocol {
199208 Log . error ( " Failed to remove features for source with id: \( sourceId) , dataId: \( dataId ?? " " ) , error: \( error) " )
200209 }
201210 }
202- item. notify ( queue: . main) { [ weak self] in
203- self ? . workItemTracker. removePartialUpdateCancelable ( for: sourceId, uuid: identifier)
204- }
205211
206212 workItemTracker. addPartialUpdateCancelable ( AnyCancelable ( item. cancel) , for: sourceId, uuid: identifier)
207213 backgroundQueue. async ( execute: item)
0 commit comments