fix: protect async preview lifetime and validate real canvas and spatial tools
这个提交包含在:
1 父节点
a3bd2ceb26
当前提交
1c3e294ce9
18 个文件已更改
+151
-45
没有与搜索条件相匹配的文件
@@ -21,6 +21,7 @@
|
||||
- (void)publishAssets:(DYAssetState*)assets histogram:(NSData*)histogram atTime:(CMTime)time;
|
||||
- (void)beginSpider:(NSData*)mesh node:(NSString*)node enabled:(double)enabled atTime:(CMTime)time;
|
||||
- (void)changeSpider:(NSData*)mesh;
|
||||
- (void)publishHistogram:(NSData*)histogram atTime:(CMTime)time;
|
||||
@end
|
||||
|
||||
static BOOL DYViewerSameValue(double a,double b) {
|
||||
@@ -81,6 +82,9 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) {
|
||||
- (void)publishAssets:(DYAssetState*)assets histogram:(NSData*)histogram atTime:(CMTime)time {
|
||||
@synchronized(self){if(_invalidated||!_snapshot||CMTimeCompare(time,_snapshotTime)!=0)return;NSMutableDictionary *next=[[_snapshot mutableCopy]autorelease];next[@"spider"]=assets.spiderMesh?:[NSData data];if(histogram)next[@"histogram"]=histogram;[_snapshot release];_snapshot=[next copy];}
|
||||
}
|
||||
- (void)publishHistogram:(NSData*)histogram atTime:(CMTime)time {
|
||||
if(histogram.length!=sizeof(DYHistogram))return;@synchronized(self){if(_invalidated||!_snapshot||CMTimeCompare(time,_snapshotTime)!=0)return;NSMutableDictionary *next=[[_snapshot mutableCopy]autorelease];next[@"histogram"]=histogram;[_snapshot release];_snapshot=[next copy];}
|
||||
}
|
||||
- (void)requestTool:(NSString*)type {
|
||||
if(![DYToolTypes()containsObject:type])return;
|
||||
dispatch_async(dispatch_get_main_queue(),^{id manager=nil;@synchronized(self){if(!self->_invalidated)manager=self->_apiManager;}if(manager)[NSNotificationCenter.defaultCenter postNotificationName:@"DYViewerToolRequested" object:manager userInfo:@{@"type":type}];});
|
||||
@@ -102,7 +106,9 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) {
|
||||
NSData *bytes=[NSData dataWithBytes:uniforms length:sizeof(*uniforms)];BOOL validate=NO;
|
||||
@synchronized(self){
|
||||
if(!_invalidated){
|
||||
NSData *sameHistogram=CMTimeCompare(_snapshotTime,time)==0?[_snapshot[@"histogram"]retain]:nil;
|
||||
[_snapshot release];_snapshot=[@{@"uniforms":bytes,@"document":frozen,@"timeValue":@(time.value),@"timeScale":@(time.timescale),@"timeEpoch":@(time.epoch)}copy];
|
||||
if(sameHistogram){NSMutableDictionary *withHistogram=[[_snapshot mutableCopy]autorelease];withHistogram[@"histogram"]=sameHistogram;[_snapshot release];_snapshot=[withHistogram copy];[sameHistogram release];}
|
||||
[_sourceDocument release];_sourceDocument=[document retain];_snapshotTime=time;
|
||||
if(_requestedGesture&&!_validationScheduled){_validationScheduled=YES;validate=YES;}
|
||||
}
|
||||
@@ -218,7 +224,7 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) {
|
||||
}
|
||||
}@finally{[a endAction:self];}
|
||||
// Re-read after DYToolManager commits its document at the outer boundary.
|
||||
if(changed){NSData *actual=DYReadAssets(self->_writerTarget,self->_writerTime).spiderMesh;if(![actual isEqual:frozen])failed=YES;else{[self->_writerLastMesh release];self->_writerLastMesh=[frozen copy];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self->_apiManager];}}
|
||||
if(changed){[a startAction:self];NSData *actual=nil;@try{actual=[DYReadAssets(self->_writerTarget,self->_writerTime).spiderMesh retain];}@finally{[a endAction:self];}BOOL saved=[actual isEqual:frozen];[actual release];if(!saved)failed=YES;else{[self->_writerLastMesh release];self->_writerLastMesh=[frozen copy];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self->_apiManager];}}
|
||||
if(failed)[self closeWriter];
|
||||
});[frozen release];
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户