fix: Open with crashing on macOS

#1070
This commit is contained in:
WerWolv 2023-05-14 18:35:35 +02:00
parent a5498995ff
commit 5027f36d95
2 changed files with 19 additions and 1 deletions

View file

@ -10,6 +10,8 @@
#include <stdlib.h>
#include <stdint.h>
#import <Cocoa/Cocoa.h>
void openWebpageMacos(const char *url) {
CFURLRef urlRef = CFURLCreateWithBytes(NULL, (uint8_t*)(url), strlen(url), kCFStringEncodingASCII, NULL);
LSOpenCFURLRef(urlRef, NULL);
@ -30,4 +32,20 @@
return [[NSScreen mainScreen] backingScaleFactor];
}
@interface HexDocument : NSDocument
@property (nonatomic, strong) NSData *fileData;
@end
@implementation HexDocument
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
// Set the file data to the given data
self.fileData = data;
return YES;
}
@end
#endif

View file

@ -20,7 +20,7 @@
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>NSDocumentClass</key>
<string>NSDocument</string>
<string>HexDocument</string>
<key>CFBundleTypeName</key>
<string>All Files</string>
</dict>