From c4af628d144847ca352facc0a79f492714842bec Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 5 Apr 2012 14:43:20 +0100 Subject: [PATCH] Avoided repeated calls to dladdr(), which could cause problems in some plugin situations. --- modules/juce_core/native/juce_posix_SharedCode.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index 25984a2a69..902b05fe7d 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -571,9 +571,18 @@ File juce_getExecutableFile() #if JUCE_ANDROID return File (android.appFile); #else - Dl_info exeInfo; - dladdr ((void*) juce_getExecutableFile, &exeInfo); // (can't be a const void* on android) - return File::getCurrentWorkingDirectory().getChildFile (CharPointer_UTF8 (exeInfo.dli_fname)); + struct DLAddrReader + { + static String getFilename() + { + Dl_info exeInfo; + dladdr ((void*) juce_getExecutableFile, &exeInfo); + return CharPointer_UTF8 (exeInfo.dli_fname); + } + }; + + static String filename (DLAddrReader::getFilename()); + return File::getCurrentWorkingDirectory().getChildFile (filename); #endif }