summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-08-10 14:14:22 +0200
committerMatthew Cattell <matthew.cattell@nokia.com>2011-08-16 15:38:48 +0200
commit06f6b71ba43e8302d61d2c3cb7118d9dbf7a3c98 (patch)
treee907e3c7d90ccee7fb369f2de5f11dbabfb225e3 /src
parent1ff94e314835682b178eac98c3c1be983e71c4ca (diff)
Don't set platform input context if it's not properly created.
Prevent xcb applications from failing to launch when IBus is not initialized correctly. Change-Id: I8425403e02d0eb5401f8d8bb0d012b53ab9400d9 Reviewed-on: http://codereview.qt.nokia.com/3044 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Matthew Cattell <matthew.cattell@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp5
-rw-r--r--src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp10
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp1
4 files changed, 14 insertions, 4 deletions
diff --git a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp
index 55c0c4b249..4bfd41cf14 100644
--- a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp
+++ b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp
@@ -89,6 +89,11 @@ QIBusPlatformInputContext::~QIBusPlatformInputContext (void)
delete d;
}
+bool QIBusPlatformInputContext::isValid() const
+{
+ return d->valid;
+}
+
void QIBusPlatformInputContext::mouseHandler (int x, QMouseEvent *event)
{
QPlatformInputContext::mouseHandler (x, event);
diff --git a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h
index 6912fe4c20..74f7da8d41 100644
--- a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h
+++ b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h
@@ -53,6 +53,8 @@ public:
QIBusPlatformInputContext();
~QIBusPlatformInputContext();
+ bool isValid() const;
+
void mouseHandler(int x, QMouseEvent *event);
void reset(void);
void update(void);
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 3053cba81e..e97b9f2121 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -99,10 +99,14 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters)
m_fontDatabase = new QGenericUnixFontDatabase();
m_nativeInterface = new QXcbNativeInterface;
-#if defined(XCB_USE_IBUS)
- m_inputContext = new QIBusPlatformInputContext;
-#else
m_inputContext = 0;
+#if defined(XCB_USE_IBUS)
+ QIBusPlatformInputContext *context = new QIBusPlatformInputContext;
+ if (context->isValid()) {
+ m_inputContext = context;
+ } else {
+ delete context;
+ }
#endif
}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index adaed53106..6f37c078a1 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -49,7 +49,6 @@
#include <private/qguiapplication_p.h>
#include <stdio.h>
-#define XCB_USE_IBUS
#if defined(XCB_USE_IBUS)
#include "QtPlatformSupport/qibusplatforminputcontext.h"
#endif