-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathOcctAisOffscreen.objc.mm
More file actions
60 lines (46 loc) · 1.76 KB
/
OcctAisOffscreen.objc.mm
File metadata and controls
60 lines (46 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import <Cocoa/Cocoa.h>
#include <Cocoa_LocalPool.hxx>
#include <Message.hxx>
//! Main Cocoa application responder - minimal implementation for offscreen viewer.
@interface OcctTestNSResponder : NSObject <NSApplicationDelegate>
{
}
//! Default constructor.
- (id ) init;
//! Access singleton.
+ (OcctTestNSResponder* ) sharedInstance;
//! Dummy method for thread-safety Cocoa initialization.
+ (void ) doDummyThread: (id )theParam;
@end
@implementation OcctTestNSResponder
- (id )init
{
self = [super init];
return self;
}
// Singletone implementation
+ (OcctTestNSResponder* ) sharedInstance
{
static OcctTestNSResponder* TheAppResponder = [[super allocWithZone: nullptr] init];
return TheAppResponder;
}
+ (id ) allocWithZone: (NSZone* )theZone { return [[self sharedInstance] retain]; }
- (id ) copyWithZone: (NSZone* )theZone { return self; }
- (id ) retain { return self; }
- (NSUInteger ) retainCount { return NSUIntegerMax; }
- (oneway void ) release {}
- (id ) autorelease { return self; }
- (BOOL ) application: (NSApplication* )theApplication openFile: (NSString* )theFilename { return YES; }
- (void ) applicationDidFinishLaunching: (NSNotification* )theNotification {}
- (void ) applicationWillTerminate: (NSNotification* )theNotification {}
+ (void ) doDummyThread: (id )theParam {}
@end
void occtNSAppCreate()
{
// create dummy NSThread to ensure Cocoa thread-safety
[NSThread detachNewThreadSelector: @selector(doDummyThread: ) toTarget: [OcctTestNSResponder class] withObject: nullptr];
NSApplication* anAppNs = [NSApplication sharedApplication];
OcctTestNSResponder* anAppResp = [OcctTestNSResponder sharedInstance];
[anAppNs setDelegate: anAppResp];
//[anAppNs run]; // Cocoa event loop
}