comparison mac/dw.m @ 1953:77d156c3f01c

Mac: Added a safeCall method to DWObject to make it easier to run things on the main thread. AppKit 10.14 is throwing a lot of exceptions for doing things on non-main threads that it did not complain about in previous versions. Controls with issues seem to be container, tree, list/combo box.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 12 Jul 2019 02:03:09 +0000
parents 8ce5c562348f
children 85229fe9ae5a
comparison
equal deleted inserted replaced
1952:8ce5c562348f 1953:77d156c3f01c
948 else 948 else
949 [item setState:DWControlStateValueOn]; 949 [item setState:DWControlStateValueOn];
950 } 950 }
951 _event_handler(param, nil, 8); 951 _event_handler(param, nil, 8);
952 } 952 }
953 -(void)safeCall:(SEL)sel withObject:(id)param
954 {
955 if([self respondsToSelector:sel])
956 {
957 DWTID curr = pthread_self();
958
959 if(DWThread == (DWTID)-1 || DWThread == curr)
960 {
961 IMP imp = [self methodForSelector:sel];
962
963 if(imp)
964 imp(self, sel, param);
965 }
966 else
967 [self performSelectorOnMainThread:sel withObject:param waitUntilDone:YES];
968 }
969 }
953 -(void)doBitBlt:(id)param 970 -(void)doBitBlt:(id)param
954 { 971 {
955 NSValue *bi = (NSValue *)param; 972 NSValue *bi = (NSValue *)param;
956 DWBitBlt *bltinfo = (DWBitBlt *)[bi pointerValue]; 973 DWBitBlt *bltinfo = (DWBitBlt *)[bi pointerValue];
957 id bltdest = bltinfo->dest; 974 id bltdest = bltinfo->dest;
8165 if(srcp) 8182 if(srcp)
8166 { 8183 {
8167 id object = bltinfo->src = (id)srcp->image; 8184 id object = bltinfo->src = (id)srcp->image;
8168 [object retain]; 8185 [object retain];
8169 } 8186 }
8170 if(DWThread == (DWTID)-1) 8187 [DWObj safeCall:@selector(doBitBlt:) withObject:bi];
8171 [DWObj doBitBlt:bi];
8172 else
8173 [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES];
8174 DW_LOCAL_POOL_OUT; 8188 DW_LOCAL_POOL_OUT;
8175 return DW_ERROR_NONE; 8189 return DW_ERROR_NONE;
8176 } 8190 }
8177 8191
8178 /* 8192 /*