[gimp] windows: Call SetDLLDirectory() in the app
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] windows: Call SetDLLDirectory() in the app
- Date: Mon, 13 Apr 2015 10:16:12 +0000 (UTC)
commit 60197c227db92c7cf927927a3b7b2d39aaf622b1
Author: Mukund Sivaraman <muks banu com>
Date: Mon Apr 13 00:17:06 2015 +0530
windows: Call SetDLLDirectory() in the app
With this patch, there should be no more need to set PATH on Windows
before running GIMP.
This patch was tested by me and drawoc, but there could be some
undetected issues lurking. Revert if any problems arise.
app/main.c | 34 ++++++++++++++++++++++++++++++++++
libgimp/gimp.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/app/main.c b/app/main.c
index 18db832..8e2e06a 100644
--- a/app/main.c
+++ b/app/main.c
@@ -318,6 +318,40 @@ main (int argc,
if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) ("");
}
+
+ /* On Windows, set DLL search path to $INSTALLDIR/bin so that .exe
+ plug-ins in the plug-ins directory can find libgimp and file
+ library DLLs without needing to set external PATH. */
+ {
+ const gchar *install_dir;
+ gchar *bin_dir;
+ LPWSTR w_bin_dir;
+ int n;
+
+ w_bin_dir = NULL;
+ install_dir = gimp_installation_directory ();
+ bin_dir = g_build_filename (install_dir, "bin", NULL);
+
+ n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ bin_dir, -1, NULL, 0);
+ if (n == 0)
+ goto out;
+
+ w_bin_dir = g_malloc_n (n + 1, sizeof (wchar_t));
+ n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ bin_dir, -1,
+ w_bin_dir, (n + 1) * sizeof (wchar_t));
+ if (n == 0)
+ goto out;
+
+ SetDllDirectoryW (w_bin_dir);
+
+ out:
+ if (w_bin_dir)
+ g_free (w_bin_dir);
+ g_free (bin_dir);
+ }
+
#ifndef _WIN64
{
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 0d85d2d..e7b26fe 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -261,6 +261,40 @@ gimp_main (const GimpPlugInInfo *info,
if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) ("");
}
+
+ /* On Windows, set DLL search path to $INSTALLDIR/bin so that GEGL
+ file operations can find their respective file library DLLs (such
+ as jasper, etc.) without needing to set external PATH. */
+ {
+ const gchar *install_dir;
+ gchar *bin_dir;
+ LPWSTR w_bin_dir;
+ int n;
+
+ w_bin_dir = NULL;
+ install_dir = gimp_installation_directory ();
+ bin_dir = g_build_filename (install_dir, "bin", NULL);
+
+ n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ bin_dir, -1, NULL, 0);
+ if (n == 0)
+ goto out;
+
+ w_bin_dir = g_malloc_n (n + 1, sizeof (wchar_t));
+ n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ bin_dir, -1,
+ w_bin_dir, (n + 1) * sizeof (wchar_t));
+ if (n == 0)
+ goto out;
+
+ SetDllDirectoryW (w_bin_dir);
+
+ out:
+ if (w_bin_dir)
+ g_free (w_bin_dir);
+ g_free (bin_dir);
+ }
+
#ifndef _WIN64
{
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]