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>
This commit is contained in:
Samuel Rødal 2011-08-10 14:14:22 +02:00 committed by Matthew Cattell
parent 1ff94e3148
commit 06f6b71ba4
4 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -53,6 +53,8 @@ public:
QIBusPlatformInputContext();
~QIBusPlatformInputContext();
bool isValid() const;
void mouseHandler(int x, QMouseEvent *event);
void reset(void);
void update(void);

View File

@ -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
}

View File

@ -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