summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx/qqnxintegration.cpp
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2014-01-17 20:45:57 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-28 19:32:53 +0100
commitb8103a4e8174446584caf80c0bf1a006b25d9905 (patch)
tree465a99e8d15a6037e48dccbb7a7aba5530b332ea /src/plugins/platforms/qnx/qqnxintegration.cpp
parenta4ff400e25c76a32ec8252285dda043f07b19c15 (diff)
[QNX] Introduce proper screen error handling
This patch adds a new function which does the error handling for libscreen calls. The patch introduces following changes: - Libscreen errors will not crash (qFatal)the application any more but rather post a warning message. -With the "flush-screen-context" option the screen_context is always flushed when a screen function is called. This enables better correlation between the time an error happens and the time it is logged. Change-Id: Ie2456e5b746dcf917d786f3b832847d2ebbe5f1e Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Roger Maclean <rmaclean@qnx.com> Reviewed-by: Bernd Weimer <bweimer@blackberry.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxintegration.cpp')
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 5695ef433a..b39311353c 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include "qqnxglobal.h"
+
#include "qqnxintegration.h"
#if defined(QQNX_SCREENEVENTTHREAD)
#include "qqnxscreeneventthread.h"
@@ -123,6 +125,10 @@ static inline QQnxIntegration::Options parseOptions(const QStringList &paramList
options |= QQnxIntegration::FullScreenApplication;
}
+ if (!paramList.contains(QLatin1String("flush-screen-context"))) {
+ options |= QQnxIntegration::AlwaysFlushScreenContext;
+ }
+
// On Blackberry the first window is treated as a root window
#ifdef Q_OS_BLACKBERRY
if (!paramList.contains(QLatin1String("no-rootwindow"))) {
@@ -165,14 +171,12 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
#if !defined(QT_NO_DRAGANDDROP)
, m_drag(new QSimpleDrag())
#endif
- , m_options(parseOptions(paramList))
{
+ ms_options = parseOptions(paramList);
qIntegrationDebug() << Q_FUNC_INFO;
// Open connection to QNX composition manager
- errno = 0;
- int result = screen_create_context(&m_screenContext, SCREEN_APPLICATION_CONTEXT);
- if (result != 0)
- qFatal("QQnx: failed to connect to composition manager, errno=%d", errno);
+ Q_SCREEN_CRITICALERROR(screen_create_context(&ms_screenContext, SCREEN_APPLICATION_CONTEXT),
+ "Failed to create screen context");
// Not on BlackBerry, it has specialized event dispatcher which also handles navigator events
#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS)
@@ -191,7 +195,7 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
// Create/start event thread
#if defined(QQNX_SCREENEVENTTHREAD)
- m_screenEventThread = new QQnxScreenEventThread(m_screenContext, m_screenEventHandler);
+ m_screenEventThread = new QQnxScreenEventThread(ms_screenContext, m_screenEventHandler);
m_screenEventThread->start();
#endif
@@ -306,7 +310,7 @@ QQnxIntegration::~QQnxIntegration()
destroyDisplays();
// Close connection to QNX composition manager
- screen_destroy_context(m_screenContext);
+ screen_destroy_context(ms_screenContext);
#if !defined(QT_NO_OPENGL)
// Cleanup global OpenGL resources
@@ -358,10 +362,10 @@ QPlatformWindow *QQnxIntegration::createPlatformWindow(QWindow *window) const
const bool needRootWindow = options() & RootWindow;
switch (surfaceType) {
case QSurface::RasterSurface:
- return new QQnxRasterWindow(window, m_screenContext, needRootWindow);
+ return new QQnxRasterWindow(window, ms_screenContext, needRootWindow);
#if !defined(QT_NO_OPENGL)
case QSurface::OpenGLSurface:
- return new QQnxEglWindow(window, m_screenContext, needRootWindow);
+ return new QQnxEglWindow(window, ms_screenContext, needRootWindow);
#endif
default:
qFatal("QQnxWindow: unsupported window API");
@@ -444,7 +448,7 @@ QPlatformDrag *QQnxIntegration::drag() const
QVariant QQnxIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
{
qIntegrationDebug() << Q_FUNC_INFO;
- if ((hint == ShowIsFullScreen) && (m_options & FullScreenApplication))
+ if ((hint == ShowIsFullScreen) && (ms_options & FullScreenApplication))
return true;
return QPlatformIntegration::styleHint(hint);
@@ -498,11 +502,10 @@ void QQnxIntegration::createDisplays()
{
qIntegrationDebug() << Q_FUNC_INFO;
// Query number of displays
- errno = 0;
- int displayCount;
- int result = screen_get_context_property_iv(m_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT, &displayCount);
- if (result != 0)
- qFatal("QQnxIntegration: failed to query display count, errno=%d", errno);
+ int displayCount = 0;
+ int result = screen_get_context_property_iv(ms_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT,
+ &displayCount);
+ Q_SCREEN_CRITICALERROR(result, "Failed to query display count");
if (displayCount < 1) {
// Never happens, even if there's no display, libscreen returns 1
@@ -510,23 +513,20 @@ void QQnxIntegration::createDisplays()
}
// Get all displays
- errno = 0;
screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount);
- result = screen_get_context_property_pv(m_screenContext, SCREEN_PROPERTY_DISPLAYS, (void **)displays);
- if (result != 0)
- qFatal("QQnxIntegration: failed to query displays, errno=%d", errno);
+ result = screen_get_context_property_pv(ms_screenContext, SCREEN_PROPERTY_DISPLAYS,
+ (void **)displays);
+ Q_SCREEN_CRITICALERROR(result, "Failed to query displays");
// If it's primary, we create a QScreen for it even if it's not attached
// since Qt will dereference QGuiApplication::primaryScreen()
createDisplay(displays[0], /*isPrimary=*/true);
for (int i=1; i<displayCount; i++) {
- int isAttached = 0;
- result = screen_get_display_property_iv(displays[i], SCREEN_PROPERTY_ATTACHED, &isAttached);
- if (result != 0) {
- qWarning("QQnxIntegration: failed to query display attachment, errno=%d", errno);
- isAttached = 1; // assume attached
- }
+ int isAttached = 1;
+ result = screen_get_display_property_iv(displays[i], SCREEN_PROPERTY_ATTACHED,
+ &isAttached);
+ Q_SCREEN_CHECKERROR(result, "Failed to query display attachment");
if (!isAttached) {
qIntegrationDebug() << Q_FUNC_INFO << "Skipping non-attached display" << i;
@@ -540,7 +540,7 @@ void QQnxIntegration::createDisplays()
void QQnxIntegration::createDisplay(screen_display_t display, bool isPrimary)
{
- QQnxScreen *screen = new QQnxScreen(m_screenContext, display, isPrimary);
+ QQnxScreen *screen = new QQnxScreen(ms_screenContext, display, isPrimary);
m_screens.append(screen);
screenAdded(screen);
screen->adjustOrientation();
@@ -587,11 +587,20 @@ QQnxScreen *QQnxIntegration::primaryDisplay() const
return m_screens.first();
}
-QQnxIntegration::Options QQnxIntegration::options() const
+QQnxIntegration::Options QQnxIntegration::options()
{
- return m_options;
+ return ms_options;
}
+screen_context_t QQnxIntegration::screenContext()
+{
+ return ms_screenContext;
+}
+
+screen_context_t QQnxIntegration::ms_screenContext = 0;
+
+QQnxIntegration::Options QQnxIntegration::ms_options = 0;
+
bool QQnxIntegration::supportsNavigatorEvents() const
{
// If QQNX_PPS or Q_OS_BLACKBERRY is defined then we have navigator