display: fix null pointer dereference with tablet
authorJinhyung Jo <jinhyung.jo@samsung.com>
Mon, 12 Dec 2016 11:56:04 +0000 (20:56 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 14 Dec 2016 11:05:39 +0000 (20:05 +0900)
Check whether the touchscreen device is accessible.

Change-Id: I85956f7b13ac534c738797843bc411d128eebc08
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
tizen/src/ui/displayglwidget.cpp

index 14aa91b..e49e516 100644 (file)
@@ -402,22 +402,26 @@ void DisplayGLWidget::initializeGL()
     mTexCoords[10] = 0;
     mTexCoords[11] = 1;
 
-    GLuint curTexture = 0;
-    mFuncs->glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&curTexture);
 
-    const QImage img = getTouchScreenHelper()->getMtTracker()->getPointImage();
-    mFuncs->glGenTextures(1, &mtTexture);
-    mFuncs->glBindTexture(GL_TEXTURE_2D, mtTexture);
-    mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-    mFuncs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_BGRA,
-                         GL_UNSIGNED_INT_8_8_8_8_REV,
-                         (const void *)img.constBits());
-    mFuncs->glBindTexture(GL_TEXTURE_2D, curTexture);
+    if (isTsEnabled) {
+        GLuint curTexture = 0;
+        mFuncs->glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&curTexture);
+        const QImage img = getTouchScreenHelper()->getMtTracker()->getPointImage();
+        mFuncs->glGenTextures(1, &mtTexture);
+        mFuncs->glBindTexture(GL_TEXTURE_2D, mtTexture);
+        mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+        mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+        mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+        mFuncs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_BGRA,
+                             GL_UNSIGNED_INT_8_8_8_8_REV,
+                             (const void *)img.constBits());
+        mFuncs->glBindTexture(GL_TEXTURE_2D, curTexture);
+    }
 
     if (!maskQImage.isNull()) {
+        GLuint curTexture = 0;
+        mFuncs->glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&curTexture);
         mFuncs->glGenTextures(1, &maskTexture);
         mFuncs->glBindTexture(GL_TEXTURE_2D, maskTexture);
         mFuncs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);