javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_symbian.cpp
changeset 79 2f468c1958d0
parent 48 e0d6e9bd3ca7
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_symbian.cpp	Fri Sep 17 08:28:21 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_symbian.cpp	Mon Oct 04 00:10:53 2010 +0300
@@ -318,8 +318,7 @@
         return false;
     }
     
-    if((mMainSurface.localSurfaceInUse) && 
-       (mMainSurface.localSurface->width() == mMainSurface.widget->width()) && 
+    if((mMainSurface.localSurface->width() == mMainSurface.widget->width()) && 
        (mMainSurface.localSurface->height() == mMainSurface.widget->height()))
     {
         return true;
@@ -362,7 +361,8 @@
         }
         else 
         {
-            // We have valid local surface so just return
+            // We have valid local surface so make sure its active and return
+            mMainSurface.localSurfaceInUse = true;
             return;
         }
     }
@@ -386,15 +386,19 @@
     
     // We got window surface so extract information
     QPaintDevice* device = surface->paintDevice();
+    QPaintEngine* engine = NULL;
+    
+    // If the device is active it means that some painter is attached to the widget,
+    // if not then we attach our own painter to do the job
     if(device->paintingActive())
     {
-        throw GfxException(EGfxErrorIllegalState, "Internal error: Device active when refreshing data");  
+        engine = device->paintEngine();
     }
-    
-    // Attach painter to device in oder to see which type 
-    // of device it is working on
-    mPainter.begin(device);
-    QPaintEngine* engine = mPainter.paintEngine();
+    else
+    {
+        mPainter.begin(device);
+        engine = mPainter.paintEngine();
+    }
     
     // determine the surface type based on the engine used
     // as Qt does not provide exact info of the surface type
@@ -420,8 +424,11 @@
             throw GfxException(EGfxErrorIllegalArgument, "Unsupported widget window surface type");
     }
     
-    // release painter
-    mPainter.end();
+    // release painter if its active
+    if(mPainter.isActive())
+    {
+        mPainter.end();
+    }
     mMainSurface.qSurface = surface;
     mMainSurface.device = device;
     mMainSurface.localSurfaceInUse = false;