Commit 811b86fa authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

Mention G_WIN32_DLLMAIN_FOR_DLL_NAME() will be deprecated in the future.

2008-02-24  Tor Lillqvist  <tml@novell.com>

	* glib/gutils.h: Mention G_WIN32_DLLMAIN_FOR_DLL_NAME() will be
	deprecated in the future.

	* glib/gutils.c: Drop use of G_WIN32_DLLMAIN_FOR_DLL_NAME(). Use a
	minimal DllMain() instead that just saves the DLL handle.
	(g_win32_get_system_data_dirs_for_module, _glib_get_locale_dir)
	(get_module_share_dir): Use
	g_win32_get_package_installation_directory_of_module().


svn path=/trunk/; revision=6570
parent 3af00194
......@@ -30,6 +30,15 @@
* glib/glib.symbols: Add it.
* glib/gutils.h: Mention G_WIN32_DLLMAIN_FOR_DLL_NAME() will be
deprecated in the future.
* glib/gutils.c: Drop use of G_WIN32_DLLMAIN_FOR_DLL_NAME(). Use a
minimal DllMain() instead that just saves the DLL handle.
(g_win32_get_system_data_dirs_for_module, _glib_get_locale_dir)
(get_module_share_dir): Use
g_win32_get_package_installation_directory_of_module().
2008-02-23 Matthias Clasen <mclasen@redhat.com>
* NEWS: Updates
......
......@@ -133,7 +133,18 @@ const guint glib_binary_age = GLIB_BINARY_AGE;
#ifdef G_PLATFORM_WIN32
G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
static HMODULE glib_dll = NULL;
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
glib_dll = hinstDLL;
return TRUE;
}
#endif
......@@ -2428,7 +2439,7 @@ get_module_for_address (gconstpointer address)
static gboolean beenhere = FALSE;
typedef BOOL (WINAPI *t_GetModuleHandleExA) (DWORD, LPCTSTR, HMODULE *);
static t_GetModuleHandleExA p_GetModuleHandleExA = NULL;
HMODULE hmodule;
HMODULE hmodule = NULL;
if (!address)
return NULL;
......@@ -2458,27 +2469,14 @@ static gchar *
get_module_share_dir (gconstpointer address)
{
HMODULE hmodule;
gchar *filename = NULL;
gchar *p, *retval;
wchar_t wfilename[MAX_PATH];
gchar *filename;
gchar *retval;
hmodule = get_module_for_address (address);
if (hmodule == NULL)
return NULL;
if (GetModuleFileNameW (hmodule, wfilename, G_N_ELEMENTS (wfilename)))
filename = g_utf16_to_utf8 (wfilename, -1, NULL, NULL, NULL);
if (filename == NULL)
return NULL;
if ((p = strrchr (filename, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
p = strrchr (filename, G_DIR_SEPARATOR);
if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0))
*p = '\0';
filename = g_win32_get_package_installation_directory_of_module (hmodule);
retval = g_build_filename (filename, "share", NULL);
g_free (filename);
......@@ -2493,6 +2491,7 @@ g_win32_get_system_data_dirs_for_module (gconstpointer address)
static GHashTable *per_module_data_dirs = NULL;
gchar **retval;
gchar *p;
gchar *exe_root;
if (address)
{
......@@ -2553,13 +2552,20 @@ g_win32_get_system_data_dirs_for_module (gconstpointer address)
if (p)
g_array_append_val (data_dirs, p);
p = g_win32_get_package_installation_subdirectory (NULL, dll_name, "share");
if (p)
g_array_append_val (data_dirs, p);
if (glib_dll != NULL)
{
gchar *glib_root = g_win32_get_package_installation_directory_of_module (glib_dll);
p = g_build_filename (glib_root, "share", NULL);
if (p)
g_array_append_val (data_dirs, p);
g_free (glib_root);
}
p = g_win32_get_package_installation_subdirectory (NULL, NULL, "share");
exe_root = g_win32_get_package_installation_directory_of_module (NULL);
p = g_build_filename (exe_root, "share", NULL);
if (p)
g_array_append_val (data_dirs, p);
g_free (exe_root);
retval = (gchar **) g_array_free (data_dirs, FALSE);
......@@ -3149,10 +3155,11 @@ _g_utils_thread_init (void)
static gchar *
_glib_get_locale_dir (void)
{
gchar *install_dir, *locale_dir;
gchar *install_dir = NULL, *locale_dir;
gchar *retval = NULL;
install_dir = g_win32_get_package_installation_directory (GETTEXT_PACKAGE, dll_name);
if (glib_dll != NULL)
install_dir = g_win32_get_package_installation_directory_of_module (glib_dll);
if (install_dir)
{
......
......@@ -427,6 +427,12 @@ const gchar * glib_check_version (guint required_major,
G_END_DECLS
/*
* This macro will be deprecated in the future. This DllMain() is too
* complex. It is recommended to have a DLlMain() that just saves the
* handle to the DLL and then use that handle in normal code instead,
* for instance passing it to
* g_win32_get_package_installation_directory_of_module().
*
* On Windows, this macro defines a DllMain function that stores the
* actual DLL name that the code being compiled will be included in.
* STATIC should be empty or 'static'. DLL_NAME is the name of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment