From 3c9c350bc06784783577851a80929c55de826682 Mon Sep 17 00:00:00 2001 From: Bastian Germann Date: Tue, 1 Sep 2026 09:30:06 +0200 Subject: [PATCH] win32: Set Enchant prefix dir to install location Enchant looks for its providers (including the WinSpell spellcheck provider) under a hardcoded default path derived from its build prefix, which is C:\gtk-build\gtk\x64\release\lib\enchant-2 when built via gvsbuild. After installation, the provider DLLs live under ZoiteChat's own install directory, so Enchant fails to find them and spellcheck silently stops working. Call enchant_set_prefix_dir() to redirect Enchant's provider search to before the first enchant_broker_init(). enchant_set_prefix_dir() expects the installation prefix itself; Enchant adds lib\enchant-2 when searching for providers. The symbol is loaded optionally since it may not exist in older Enchant builds; if missing, behavior is unchanged. --- src/fe-gtk/sexy-spell-entry.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index 058356d0..107a0f3a 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -113,6 +113,9 @@ static void (*enchant_dict_describe) (struct EnchantDict * dict, EnchantDictDesc static void (*enchant_dict_free_suggestions) (struct EnchantDict * dict, char **suggestions); static void (*enchant_dict_store_replacement) (struct EnchantDict * dict, const char *const mis, ssize_t mis_len, const char *const cor, ssize_t cor_len); static char ** (*enchant_dict_suggest) (struct EnchantDict * dict, const char *const word, ssize_t len, size_t * out_n_suggs); +#ifdef G_OS_WIN32 +static void (*enchant_set_prefix_dir) (const char *dir); +#endif static gboolean have_enchant = FALSE; struct _SexySpellEntryPriv @@ -257,6 +260,23 @@ initialize_enchant (void) MODULE_SYMBOL("enchant_dict_store_replacement", enchant_dict_store_replacement, NULL) MODULE_SYMBOL("enchant_dict_suggest", enchant_dict_suggest, NULL) + +#ifdef G_OS_WIN32 + if (g_module_symbol(enchant, "enchant_set_prefix_dir", &funcptr)) + { + gchar *install_dir; + + enchant_set_prefix_dir = funcptr; + install_dir = g_win32_get_package_installation_directory_of_module(NULL); + + if (install_dir) + { + enchant_set_prefix_dir(install_dir); + g_info("Enchant prefix dir set to %s", install_dir); + g_free(install_dir); + } + } +#endif } static void