summaryrefslogtreecommitdiff
path: root/plugins/AdvaImg/src/FreeImage/Plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AdvaImg/src/FreeImage/Plugin.cpp')
-rw-r--r--plugins/AdvaImg/src/FreeImage/Plugin.cpp77
1 files changed, 75 insertions, 2 deletions
diff --git a/plugins/AdvaImg/src/FreeImage/Plugin.cpp b/plugins/AdvaImg/src/FreeImage/Plugin.cpp
index 7ded36ebc2..6f88e47e68 100644
--- a/plugins/AdvaImg/src/FreeImage/Plugin.cpp
+++ b/plugins/AdvaImg/src/FreeImage/Plugin.cpp
@@ -218,7 +218,12 @@ FreeImage_GetPluginList() {
void DLL_CALLCONV
FreeImage_Initialise(BOOL load_local_plugins_only) {
if (s_plugin_reference_count++ == 0) {
-
+
+ /*
+ Note: initialize all singletons here
+ in order to avoid race conditions with multi-threading
+ */
+
// initialise the TagLib singleton
TagLib& s = TagLib::instance();
@@ -257,7 +262,7 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
//s_plugins->AddNode(InitXPM);
//s_plugins->AddNode(InitDDS);
s_plugins->AddNode(InitGIF);
- //s_plugins->AddNode(InitHDR);
+ //s_plugins->AddNode(InitHDR);
//s_plugins->AddNode(InitG3);
//s_plugins->AddNode(InitSGI);
//s_plugins->AddNode(InitEXR);
@@ -266,6 +271,74 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
//s_plugins->AddNode(InitPFM);
//s_plugins->AddNode(InitPICT);
//s_plugins->AddNode(InitRAW);
+ //s_plugins->AddNode(InitWEBP);
+//#if !(defined(_MSC_VER) && (_MSC_VER <= 1310))
+ //s_plugins->AddNode(InitJXR);
+//#endif // unsupported by MS Visual Studio 2003 !!!
+
+ // external plugin initialization
+
+#ifdef _WIN32
+ if (!load_local_plugins_only) {
+ int count = 0;
+ char buffer[MAX_PATH + 200];
+ char current_dir[2 * _MAX_PATH], module[2 * _MAX_PATH];
+ BOOL bOk = FALSE;
+
+ // store the current directory. then set the directory to the application location
+
+ if (GetCurrentDirectoryA(2 * _MAX_PATH, current_dir) != 0) {
+ if (GetModuleFileNameA(NULL, module, 2 * _MAX_PATH) != 0) {
+ char *last_point = strrchr(module, '\\');
+
+ if (last_point) {
+ *last_point = '\0';
+
+ bOk = SetCurrentDirectoryA(module);
+ }
+ }
+ }
+
+ // search for plugins
+
+ while (count < s_search_list_size) {
+ _finddata_t find_data;
+ long find_handle;
+
+ strcpy(buffer, s_search_list[count]);
+ strcat(buffer, "*.fip");
+
+ if ((find_handle = (long)_findfirst(buffer, &find_data)) != -1L) {
+ do {
+ strcpy(buffer, s_search_list[count]);
+ strncat(buffer, find_data.name, MAX_PATH + 200);
+
+ HINSTANCE instance = LoadLibraryA(buffer);
+
+ if (instance != NULL) {
+ FARPROC proc_address = GetProcAddress(instance, "_Init@8");
+
+ if (proc_address != NULL) {
+ s_plugins->AddNode((FI_InitProc)proc_address, (void *)instance);
+ } else {
+ FreeLibrary(instance);
+ }
+ }
+ } while (_findnext(find_handle, &find_data) != -1L);
+
+ _findclose(find_handle);
+ }
+
+ count++;
+ }
+
+ // restore the current directory
+
+ if (bOk) {
+ SetCurrentDirectoryA(current_dir);
+ }
+ }
+#endif // _WIN32
}
}
}