mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Use default broken image for invalid images
This commit is contained in:
@@ -1789,7 +1789,7 @@ void Run(struct Application *app, int argc, char **argv) {
|
||||
// Disable damn smart quotes
|
||||
// Credit: https://stackoverflow.com/a/31640511
|
||||
id userDefaults = msg_reg(c("NSUserDefaults"), s("standardUserDefaults"));
|
||||
((id(*)(id, SEL, id, id))objc_msgSend)(userDefaults, s("setBool:forKey:"), NO, str("NSAutomaticQuoteSubstitutionEnabled"));
|
||||
((id(*)(id, SEL, BOOL, id))objc_msgSend)(userDefaults, s("setBool:forKey:"), false, str("NSAutomaticQuoteSubstitutionEnabled"));
|
||||
|
||||
// Setup drag message handler
|
||||
msg_id_id(manager, s("addScriptMessageHandler:name:"), app->delegate, str("windowDrag"));
|
||||
@@ -1939,6 +1939,24 @@ void Quit(struct Application *app) {
|
||||
Hide(app);
|
||||
}
|
||||
|
||||
id createImageFromBase64Data(const char *data, bool isTemplateImage) {
|
||||
id nsdata = ALLOC("NSData");
|
||||
id imageData = ((id(*)(id, SEL, id, int))objc_msgSend)(nsdata, s("initWithBase64EncodedString:options:"), str(data), 0);
|
||||
|
||||
// If it's not valid base64 data, use the broken image
|
||||
if ( imageData == NULL ) {
|
||||
imageData = ((id(*)(id, SEL, id, int))objc_msgSend)(nsdata, s("initWithBase64EncodedString:options:"), str(BrokenImage), 0);
|
||||
}
|
||||
id result = ALLOC("NSImage");
|
||||
msg_id(result, s("initWithData:"), imageData);
|
||||
|
||||
if( isTemplateImage ) {
|
||||
msg_bool(result, s("setTemplate:"), YES);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void* NewApplication(const char *title, int width, int height, int resizable, int devtools, int fullscreen, int startHidden, int logLevel, int hideWindowOnClose) {
|
||||
|
||||
// Load the tray icons
|
||||
|
||||
Reference in New Issue
Block a user