javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp
changeset 50 023eef975703
parent 49 35baca0e7a2e
child 57 59b3b4473dc8
equal deleted inserted replaced
49:35baca0e7a2e 50:023eef975703
  5330         SWT_LOG_DATA_1("handle=%x ", aHandle );
  5330         SWT_LOG_DATA_1("handle=%x ", aHandle );
  5331 
  5331 
  5332         jboolean isCopy;
  5332         jboolean isCopy;
  5333         jint* imagesHandles = NULL;
  5333         jint* imagesHandles = NULL;
  5334 
  5334 
  5335         const QPixmap** detailImages = const_cast<const QPixmap**>(new QPixmap*[aDetailImageCount]);
  5335         QPixmap** detailImages = new QPixmap*[aDetailImageCount];
  5336         if( !detailImages )
  5336         if( !detailImages )
  5337             {
  5337             {
  5338             throw std::bad_alloc();
  5338             throw std::bad_alloc();
  5339             }
  5339             }
  5340         if(aDetailImageHandles)
  5340         if(aDetailImageHandles)
  5341             {
  5341             {
  5342             imagesHandles = aJniEnv->GetIntArrayElements(aDetailImageHandles, &isCopy);
  5342             imagesHandles = aJniEnv->GetIntArrayElements(aDetailImageHandles, &isCopy);
  5343             if( !imagesHandles )
  5343             if( !imagesHandles )
  5344                 {
  5344                 {
       
  5345                 delete [] detailImages;
  5345                 throw std::bad_alloc();
  5346                 throw std::bad_alloc();
  5346                 }
  5347                 }
  5347             for(int i = 0; i < aDetailImageCount; i++)
  5348             for(int i = 0; i < aDetailImageCount; i++)
  5348                 {
  5349                 {
  5349                 detailImages[i] = reinterpret_cast< QPixmap* >( imagesHandles[i] );
  5350                 detailImages[i] = reinterpret_cast< QPixmap* >( imagesHandles[i] );
  5350                 }
  5351                 }
  5351             aJniEnv->ReleaseIntArrayElements(aDetailImageHandles, imagesHandles, JNI_ABORT);
  5352             aJniEnv->ReleaseIntArrayElements(aDetailImageHandles, imagesHandles, JNI_ABORT);
  5352             }
  5353             }
  5353 
  5354 
  5354         const QPixmap** headingImages =  const_cast<const QPixmap**>(new QPixmap*[aHeadingImageCount]);
  5355         QPixmap** headingImages = new QPixmap*[aHeadingImageCount];
  5355         if( !headingImages )
  5356         if( !headingImages )
  5356             {
  5357             {
       
  5358             delete [] detailImages; // allocated earlier
  5357             throw std::bad_alloc();
  5359             throw std::bad_alloc();
  5358             }
  5360             }
  5359         if(aHeadingImageHandles)
  5361         if(aHeadingImageHandles)
  5360             {
  5362             {
  5361             imagesHandles = aJniEnv->GetIntArrayElements(aHeadingImageHandles, &isCopy);
  5363             imagesHandles = aJniEnv->GetIntArrayElements(aHeadingImageHandles, &isCopy);
  5362             if( !imagesHandles )
  5364             if( !imagesHandles )
  5363                 {
  5365                 {
       
  5366                 delete [] detailImages;
       
  5367                 delete [] headingImages;
  5364                 throw std::bad_alloc();
  5368                 throw std::bad_alloc();
  5365                 }
  5369                 }
  5366             for(int i = 0; i < aHeadingImageCount; i++)
  5370             for(int i = 0; i < aHeadingImageCount; i++)
  5367                 {
  5371                 {
  5368                 headingImages[i] = reinterpret_cast< QPixmap* >( imagesHandles[i] );
  5372                 headingImages[i] = reinterpret_cast< QPixmap* >( imagesHandles[i] );
  5369                 }
  5373                 }
  5370             aJniEnv->ReleaseIntArrayElements(aHeadingImageHandles, imagesHandles, JNI_ABORT);
  5374             aJniEnv->ReleaseIntArrayElements(aHeadingImageHandles, imagesHandles, JNI_ABORT);
  5371             }
  5375             }
  5372 
  5376 
  5373         ListModel* listDataModel = reinterpret_cast< ListModel* > ( aHandle );
  5377         ListModel* listDataModel = reinterpret_cast< ListModel* > ( aHandle );
  5374         listDataModel->appendItem( swtApp->jniUtils().JavaStringToQString( aJniEnv, aDetailText ), detailImages, aDetailImageCount,
  5378         listDataModel->appendItem( swtApp->jniUtils().JavaStringToQString( aJniEnv, aDetailText ), 
  5375             swtApp->jniUtils().JavaStringToQString( aJniEnv, aHeadingText ), headingImages, aHeadingImageCount );
  5379             const_cast<const QPixmap**>(detailImages), aDetailImageCount,
       
  5380             swtApp->jniUtils().JavaStringToQString( aJniEnv, aHeadingText ), 
       
  5381             const_cast<const QPixmap**>(headingImages), aHeadingImageCount );
  5376         }
  5382         }
  5377     SWT_CATCH
  5383     SWT_CATCH
  5378     }
  5384     }
  5379 
  5385 
  5380 JNIEXPORT void  JNICALL OS_NATIVE( ListModel_1insert__ILjava_lang_String_2I )
  5386 JNIEXPORT void  JNICALL OS_NATIVE( ListModel_1insert__ILjava_lang_String_2I )
 11660     SWT_TRY
 11666     SWT_TRY
 11661         {
 11667         {
 11662         SWT_LOG_JNI_CALL();
 11668         SWT_LOG_JNI_CALL();
 11663         SWT_LOG_DATA_2( "handle=%x duration=%x", aHandle, aDuration );
 11669         SWT_LOG_DATA_2( "handle=%x duration=%x", aHandle, aDuration );
 11664         CSwtMobileDevice* mobileDevice =  reinterpret_cast<CSwtMobileDevice*>(aHandle);
 11670         CSwtMobileDevice* mobileDevice =  reinterpret_cast<CSwtMobileDevice*>(aHandle);
 11665         vibraSupport = mobileDevice->Vibrate((TTimeIntervalMicroSeconds32)static_cast<TInt>(aDuration));
 11671         vibraSupport = mobileDevice->Vibrate(static_cast<TInt>(aDuration));
 11666         }
 11672         }
 11667     SWT_CATCH
 11673     SWT_CATCH
 11668 #endif
 11674 #endif
 11669     return ( vibraSupport ? JNI_TRUE : JNI_FALSE );
 11675     return ( vibraSupport ? JNI_TRUE : JNI_FALSE );
 11670     }
 11676     }