/[svn]/gigedit/trunk/src/gigedit/MacHelper.m
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/MacHelper.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2474 - (show annotations) (download)
Sun Sep 15 18:16:21 2013 UTC (10 years, 6 months ago) by schoenebeck
File size: 1060 byte(s)
* Mac OS X: try to launch the GUI on the process's "main" thread

1 /*
2 Copyright (c) 2013 Christian Schoenebeck
3
4 This file is part of "gigedit" and released under the terms of the
5 GNU General Public License version 2.
6 */
7
8 #import "MacHelper.h"
9 #import <Cocoa/Cocoa.h>
10 #import <stdio.h>
11
12 @interface MacHelper : NSObject {
13 @public
14 void (*m_fn)(void* info);
15 void* m_info;
16 }
17 @end
18
19 @implementation MacHelper
20
21 - (id)init {
22 if ((self = [super init])) {
23 m_fn = nil;
24 m_info = nil;
25 }
26 return self;
27 }
28
29 - (void)runCFunc {
30 (*m_fn)(m_info);
31 }
32
33 @end
34
35 #if defined(__cplusplus)
36 extern "C" {
37 #endif // __cplusplus
38
39 void macHelperRunCFuncOnMainThread(void (*fn)(void* info), void* info) {
40 MacHelper* obj = [[MacHelper alloc] init];
41 obj->m_fn = fn;
42 obj->m_info = info;
43 printf("perfoming selector on main thread ...\n"); fflush(stdout);
44 [obj performSelectorOnMainThread:@selector(runCFunc) withObject:obj waitUntilDone:NO];
45 printf("Selector scheduled async. (on main thread).\n"); fflush(stdout);
46 [obj release];
47 }
48
49 #if defined(__cplusplus)
50 }
51 #endif // __cplusplus

  ViewVC Help
Powered by ViewVC