|
227 | 227 | cache->CtorFuncs.emplace(extendedClassName, poExtendedClassCtorFunc); |
228 | 228 |
|
229 | 229 | IMP newInitialize = imp_implementationWithBlock(^(id self) { |
| 230 | + if (!Runtime::IsAlive(isolate) || !isolateWrapper.IsValid()) { |
| 231 | + return; |
| 232 | + } |
230 | 233 | v8::Locker locker(isolate); |
231 | 234 | Isolate::Scope isolate_scope(isolate); |
232 | 235 | HandleScope handle_scope(isolate); |
|
261 | 264 | /// in order to make both of them destroyable/GC-able. When the JavaScript object is GC-ed we release the native counterpart as well. |
262 | 265 | void (*retain)(id, SEL) = (void (*)(id, SEL))FindNotOverridenMethod(extendedClass, @selector(retain)); |
263 | 266 | IMP newRetain = imp_implementationWithBlock(^(id self) { |
| 267 | + if (!Runtime::IsAlive(isolate) || !isolateWrapper.IsValid()) { |
| 268 | + return retain(self, @selector(retain)); |
| 269 | + } |
264 | 270 | if ([self retainCount] == 1) { |
265 | | - auto it = cache->Instances.find(self); |
266 | | - if (it != cache->Instances.end()) { |
| 271 | + auto innerCache = isolateWrapper.GetCache(); |
| 272 | + auto it = innerCache->Instances.find(self); |
| 273 | + if (it != innerCache->Instances.end()) { |
267 | 274 | v8::Locker locker(isolate); |
268 | 275 | Isolate::Scope isolate_scope(isolate); |
269 | 276 | HandleScope handle_scope(isolate); |
|
283 | 290 | void (*release)(id, SEL) = (void (*)(id, SEL))FindNotOverridenMethod(extendedClass, @selector(release)); |
284 | 291 | IMP newRelease = imp_implementationWithBlock(^(id self) { |
285 | 292 | if (!Runtime::IsAlive(isolate) || !isolateWrapper.IsValid()) { |
| 293 | + release(self, @selector(release)); |
286 | 294 | return; |
287 | 295 | } |
288 | 296 |
|
289 | 297 | if ([self retainCount] == 2) { |
290 | | - auto it = cache->Instances.find(self); |
291 | | - if (it != cache->Instances.end()) { |
| 298 | + auto innerCache = isolateWrapper.GetCache(); |
| 299 | + auto it = innerCache->Instances.find(self); |
| 300 | + if (it != innerCache->Instances.end()) { |
292 | 301 | v8::Locker locker(isolate); |
293 | 302 | Isolate::Scope isolate_scope(isolate); |
294 | 303 | HandleScope handle_scope(isolate); |
|
0 commit comments