OSX: revive GHOST_HACK_getFirstFile cause it breaks things on older OSX versions.
authorJens Verwiebe <info@jensverwiebe.de>
Thu, 25 Dec 2014 14:12:56 +0000 (15:12 +0100)
committerJens Verwiebe <info@jensverwiebe.de>
Thu, 25 Dec 2014 14:12:56 +0000 (15:12 +0100)
Dunno exactly why this was done earlier, but propose not to remove code not understood.

intern/ghost/intern/GHOST_SystemCocoa.mm
source/creator/creator.c
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

index cfa1e8bf566f4d1aea1cc3d39fd5bbef63f49c5c..61caf3f727edf1d37406e33eec8d4c4994c3293f 100644 (file)
@@ -255,6 +255,24 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
        return GHOST_kKeyUnknown;
 }
 
+#pragma mark Utility functions
+
+#define FIRSTFILEBUFLG 512
+static bool g_hasFirstFile = false;
+static char g_firstFileBuf[512];
+
+//TODO:Need to investigate this. Function called too early in creator.c to have g_hasFirstFile == true
+extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
+{
+       if (g_hasFirstFile) {
+               strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
+               buf[FIRSTFILEBUFLG - 1] = '\0';
+               return 1;
+       }
+       else {
+       return 0;
+       }
+}
 
 #pragma mark Cocoa objects
 
index efef30937304a5436c691e730b477784cec581cf..cc804946f6b75a0db0cdbbe17b3c5f7741703b17 100644 (file)
@@ -1001,7 +1001,7 @@ static int render_animation(int UNUSED(argc), const char **UNUSED(argv), void *d
                BLI_end_threaded_malloc();
        }
        else {
-               printf("\nError: no blend loaded. cannot use '-a'.\n");
+               printf("\nError: no blend loaded. GPG_ghost.cpp use '-a'.\n");
        }
        return 0;
 }
@@ -1551,7 +1551,22 @@ int main(
 #endif
 
        setCallbacks();
+       
+#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
+/* patch to ignore argument finder gives us (pid?) */
+       if (argc == 2 && strncmp(argv[1], "-psn_", 5) == 0) {
+               extern int GHOST_HACK_getFirstFile(char buf[]);
+               static char firstfilebuf[512];
+
+               argc = 1;
 
+               if (GHOST_HACK_getFirstFile(firstfilebuf)) {
+                       argc = 2;
+                       argv[1] = firstfilebuf;
+               }
+       }
+#endif
+       
 #ifdef __FreeBSD__
        fpsetmask(0);
 #endif
index 3e87b4a06d5d454edda0e311d43d400432e31677..915fe614957a02d1c905fb1c307d4d5ab1725c38 100644 (file)
@@ -80,6 +80,10 @@ extern "C"
 #include "IMB_imbuf.h"
 #include "IMB_moviecache.h"
        
+#ifdef __APPLE__
+       int GHOST_HACK_getFirstFile(char buf[]);
+#endif
+       
 // For BLF
 #include "BLF_api.h"
 #include "BLF_translation.h"
@@ -297,6 +301,12 @@ static void get_filename(int argc, char **argv, char *filename)
                if (BLI_exists(argv[argc-1])) {
                        BLI_strncpy(filename, argv[argc-1], FILE_MAX);
                }
+               if (::strncmp(argv[argc-1], "-psn_", 5)==0) {
+                       static char firstfilebuf[512];
+                       if (GHOST_HACK_getFirstFile(firstfilebuf)) {
+                               BLI_strncpy(filename, firstfilebuf, FILE_MAX);
+                       }
+               }
        }
        
        srclen -= ::strlen("MacOS/blenderplayer");