Revision: 7421
Author:   nogu.dev
Date:     Sat Jan 21 19:56:44 2012
Log:      * notify/uim-knotify4.cpp
  - (send_knotify): Check if QApplication::instance() is 0.
http://code.google.com/p/uim/source/detail?r=7421

Modified:
 /trunk/notify/uim-knotify4.cpp

=======================================
--- /trunk/notify/uim-knotify4.cpp      Sat Jan 21 19:56:35 2012
+++ /trunk/notify/uim-knotify4.cpp      Sat Jan 21 19:56:44 2012
@@ -31,6 +31,8 @@
 */
 #include <config.h>

+#include <QtGui/QApplication>
+
 #include <kdemacros.h> // for KDE_EXPORT
 #include <knotification.h>

@@ -64,8 +66,24 @@
 static uim_bool
 send_knotify(const char *msg, KNotification::StandardEvent eventId)
 {
+    if (QApplication::instance()) {
+        KNotification::event(eventId, mygettext(msg),
+            QPixmap(UIM_PIXMAPSDIR "/uim-icon.png"));
+        return UIM_TRUE;
+    }
+
+    // fake arguments
+    int argc = 1;
+    char *arg = strdup("uim");
+    char *argv[] = {arg};
+
+    QApplication app(argc, argv);
+
     KNotification::event(eventId, mygettext(msg),
         QPixmap(UIM_PIXMAPSDIR "/uim-icon.png"));
+
+    free(arg);
+
     return UIM_TRUE;
 }

Reply via email to