javauis/m3g_qt/src/jni/image2d.inl
changeset 87 1627c337e51e
parent 35 85266cc22c7f
--- a/javauis/m3g_qt/src/jni/image2d.inl	Fri Oct 15 12:29:39 2010 +0300
+++ b/javauis/m3g_qt/src/jni/image2d.inl	Fri Oct 29 11:49:32 2010 +0300
@@ -65,20 +65,11 @@
     if (aImageHandle != 0)
     {
         Java::GFX::Image* cgfxImage = reinterpret_cast<Java::GFX::Image*>(aImageHandle);
-        QImage qtImage;
-
-        if (!cgfxImage)
+        QImage qtImage = cgfxImage->toImage();
+        if (qtImage.isNull())
         {
             return 0;
         }
-        else
-        {
-            qtImage = cgfxImage->toImage();
-            if (qtImage.isNull())
-            {
-                return 0;
-            }
-        }
 
         // m3g needs format in 32bpp, i.e. in RGB32 or ARGB32 so
         // if format is not one of those convert it here
@@ -102,6 +93,7 @@
         image = m3gCreateImage((M3GInterface)aHM3g, (M3GImageFormat)aFormat, width, height, 0);
         if (image == NULL)
         {
+            M3G_DO_UNLOCK(aEnv)
             return 0;    // exception automatically raised
         }
 
@@ -109,6 +101,7 @@
         if (tempPixels == NULL)
         {
             m3gDeleteObject((M3GObject) image);
+            M3G_DO_UNLOCK(aEnv)
             return 0;
         }
 
@@ -186,6 +179,7 @@
                 if (image == NULL)
                 {
                     M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError");
+                    M3G_DO_UNLOCK(aEnv)
                     return 0;
                 }
 
@@ -199,6 +193,7 @@
                         aEnv->ReleaseByteArrayElements(aImage, image, JNI_ABORT);
                     }
                     M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError");
+                    M3G_DO_UNLOCK(aEnv)
                     return 0;
                 }