dia r3937 - in trunk: . lib



Author: hans
Date: Sat Apr 12 10:56:39 2008
New Revision: 3937
URL: http://svn.gnome.org/viewvc/dia?rev=3937&view=rev

Log:
2008-04-08  Hans Breuer  <hans breuer org>

	* lib/plug-ins.c : not being able to load a plug-in is not a critical
	issue, get rid of message_error() for these. Fixes bug #402320
	On windows also use SetErrorMode() to to suppress the systems error 
	dialog. Finally we are rewriting the error reason if the plug-in file
	exists but can not be loaded.



Modified:
   trunk/ChangeLog
   trunk/lib/plug-ins.c

Modified: trunk/lib/plug-ins.c
==============================================================================
--- trunk/lib/plug-ins.c	(original)
+++ trunk/lib/plug-ins.c	Sat Apr 12 10:56:39 2008
@@ -42,6 +42,13 @@
 #include "message.h"
 #include "dia_dirs.h"
 
+#ifdef G_OS_WIN32
+#define Rectangle Win32Rectangle
+#define WIN32_LEAN_AND_MEAN
+#include <pango/pangowin32.h>
+#undef Rectangle
+#endif
+
 struct _PluginInfo {
   GModule *module;
   gchar *filename;      /* plugin filename */
@@ -151,17 +158,31 @@
 void
 dia_plugin_load(PluginInfo *info)
 {
+#ifdef G_OS_WIN32
+  guint error_mode;
+#endif
   g_return_if_fail(info != NULL);
   g_return_if_fail(info->filename != NULL);
 
   if (info->is_loaded)
     return;
+    
+#ifdef G_OS_WIN32
+  /* suppress the systems error dialog, we can handle a plug-in not loadable */
+  error_mode = SetErrorMode (SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
+#endif
 
   info->module = g_module_open(info->filename, G_MODULE_BIND_LAZY);
+#ifdef G_OS_WIN32
+    SetErrorMode (error_mode);
+#endif
   if (!info->module) {
-    gchar *msg_utf8 = g_locale_to_utf8 (g_module_error(), -1, NULL, NULL, NULL);
-    message_error(_("Could not load plugin '%s'\n%s"), 
-                  info->filename, msg_utf8);
+    gchar *msg_utf8 = NULL;
+    /* at least on windows the systems error message is not that useful */
+    if (!g_file_test(info->filename, G_FILE_TEST_EXISTS))
+      msg_utf8 = g_locale_to_utf8 (g_module_error(), -1, NULL, NULL, NULL);
+    else
+      msg_utf8 = g_strdup_printf (_("Missing dependencies for '%s'?"), info->filename);
     /* this is eating the conversion */
     info->description = msg_utf8;
     return;
@@ -172,9 +193,6 @@
 		       (gpointer)&info->init_func)) {
     g_module_close(info->module);
     info->module = NULL;
-
-    message_error(_("Could not find plugin init function in `%s'"),
-		  info->filename);
     info->description = g_strdup(_("Missing symbol 'dia_plugin_init'"));
     return;
   }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]