aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/c_src/wxe_ps_init.c
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2013-09-24 09:53:44 +0200
committerDan Gudmundsson <[email protected]>2013-10-11 10:12:26 +0200
commitb59afc383d66c657671ed8e2acc2f9b6269a496c (patch)
treecc7e8e409f4e5b90c3c0edc9a92f314c31484ec7 /lib/wx/c_src/wxe_ps_init.c
parent3abf1b5ef82478b152581152ad3ec749e8b7edaa (diff)
downloadotp-b59afc383d66c657671ed8e2acc2f9b6269a496c.tar.gz
otp-b59afc383d66c657671ed8e2acc2f9b6269a496c.tar.bz2
otp-b59afc383d66c657671ed8e2acc2f9b6269a496c.zip
wx: Fix initializations on mac osx
Remove dummy windows and move the console to gui app code before wxWidgets gets initialized to prevent hangings on current wxWidgets svn version.
Diffstat (limited to 'lib/wx/c_src/wxe_ps_init.c')
-rw-r--r--lib/wx/c_src/wxe_ps_init.c59
1 files changed, 40 insertions, 19 deletions
diff --git a/lib/wx/c_src/wxe_ps_init.c b/lib/wx/c_src/wxe_ps_init.c
index 541d188098..7c3e820e40 100644
--- a/lib/wx/c_src/wxe_ps_init.c
+++ b/lib/wx/c_src/wxe_ps_init.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include "wxe_driver.h"
+
/* Platform specific initialisation stuff */
#ifdef _MACOSX
@@ -30,34 +31,54 @@ extern OSErr CPSSetProcessName (ProcessSerialNumber *psn, char *processname);
void * wxe_ps_init()
{
ProcessSerialNumber psn;
- NSAutoreleasePool *pool;
// Enable GUI
- GetCurrentProcess(&psn);
- char *app_title = getenv("WX_APP_TITLE");
- // Undocumented function (but no documented way of doing this exists)
- CPSSetProcessName(&psn, app_title?app_title:"Erlang");
- TransformProcessType(&psn, kProcessTransformToForegroundApplication);
- SetFrontProcess(&psn);
- // Enable Cocoa calls from Carbon app
- NSApplicationLoad();
+ if(!GetCurrentProcess(&psn)) {
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+ SetFrontProcess(&psn);
+ }
+ return (void *) 0;
+}
+
+int is_packaged_app() {
+ // Can get lost in when execing around, we use the name instead
+ /* if(mainBundle) { */
+ /* return (CFBundleGetValueForInfoDictionaryKey(mainBundle, CFSTR("CFBundlePackageType")) != nil); */
+ /* } */
+ NSString * appName = [[NSRunningApplication currentApplication] localizedName];
+ return (strncmp("beam", [appName UTF8String], 4) != 0);
+}
+
+void * wxe_ps_init2() {
+ NSAutoreleasePool *pool;
+ ProcessSerialNumber psn;
// Setup and enable gui
pool = [[NSAutoreleasePool alloc] init];
-
- NSApplication *app = [NSApplication sharedApplication];
- // Load and set icon
- NSMutableString *file = [[NSMutableString alloc] init];
- [file appendFormat:@"%s/%s", erl_wx_privdir, "erlang-logo64.png"];
- NSImage *icon = [[NSImage alloc] initWithContentsOfFile: file];
- [app setApplicationIconImage: icon];
+ if( !is_packaged_app() ) {
+ // Undocumented function (but no documented way of doing this exists)
+ char *app_title = getenv("WX_APP_TITLE");
+ if(!GetCurrentProcess(&psn)) {
+ CPSSetProcessName(&psn, app_title?app_title:"Erlang");
+ }
+ // Load and set icon
+ NSMutableString *file = [[NSMutableString alloc] init];
+ [file appendFormat:@"%s/%s", erl_wx_privdir, "erlang-logo64.png"];
+ NSImage *icon = [[NSImage alloc] initWithContentsOfFile: file];
+ [NSApp setApplicationIconImage: icon];
+ };
- return (void *) pool;
+ return pool;
}
+
/* _MACOSX */
#else
-void * wxe_ps_init()
+void * wxe_ps_init()
+{
+ return (void *) 0;
+}
+void * wxe_ps_init2()
{
return (void *) 0;
}
-#endif
+#endif