changeset 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
files mac/dw.m
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Thu Jul 11 21:40:33 2019 +0000
+++ b/mac/dw.m	Fri Jul 12 02:03:09 2019 +0000
@@ -950,6 +950,23 @@
     }
     _event_handler(param, nil, 8);
 }
+-(void)safeCall:(SEL)sel withObject:(id)param
+{
+    if([self respondsToSelector:sel])
+    {
+        DWTID curr = pthread_self();
+
+        if(DWThread == (DWTID)-1 || DWThread == curr)
+        {
+            IMP imp = [self methodForSelector:sel];
+            
+            if(imp)
+                imp(self, sel, param);
+        }
+        else
+            [self performSelectorOnMainThread:sel withObject:param waitUntilDone:YES];
+    }
+}
 -(void)doBitBlt:(id)param
 {
     NSValue *bi = (NSValue *)param;
@@ -8167,10 +8184,7 @@
         id object = bltinfo->src = (id)srcp->image;
         [object retain];
     }
-    if(DWThread == (DWTID)-1)
-        [DWObj doBitBlt:bi];
-    else
-        [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES];
+    [DWObj safeCall:@selector(doBitBlt:) withObject:bi];
     DW_LOCAL_POOL_OUT;
     return DW_ERROR_NONE;
 }