src/gui/image/qpixmap_s60.cpp
changeset 33 3e2da88830cd
parent 19 fcece45ef507
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   155 */
   155 */
   156 class QSymbianBitmapDataAccess
   156 class QSymbianBitmapDataAccess
   157 {
   157 {
   158 public:
   158 public:
   159 
   159 
   160     bool heapWasLocked;
   160     static int heapRefCount;
   161     QSysInfo::SymbianVersion symbianVersion;
   161     QSysInfo::SymbianVersion symbianVersion;
   162 
   162 
   163     explicit QSymbianBitmapDataAccess() : heapWasLocked(false)
   163     explicit QSymbianBitmapDataAccess()
   164     {
   164     {
   165         symbianVersion = QSysInfo::symbianVersion();
   165         symbianVersion = QSysInfo::symbianVersion();
   166     };
   166     };
   167 
   167 
   168     ~QSymbianBitmapDataAccess() {};
   168     ~QSymbianBitmapDataAccess() {};
   169 
   169 
   170     inline void beginDataAccess(CFbsBitmap *bitmap)
   170     inline void beginDataAccess(CFbsBitmap *bitmap)
   171     {
   171     {
   172         if (symbianVersion == QSysInfo::SV_9_2)
   172         if (symbianVersion == QSysInfo::SV_9_2) {
   173             heapWasLocked = qt_symbianFbsClient()->lockHeap();
   173             if (heapRefCount == 0)
   174         else
   174                 qt_symbianFbsClient()->lockHeap();
       
   175         } else {
   175             bitmap->LockHeap(ETrue);
   176             bitmap->LockHeap(ETrue);
       
   177         }
       
   178 
       
   179         heapRefCount++;
   176     }
   180     }
   177 
   181 
   178     inline void endDataAccess(CFbsBitmap *bitmap)
   182     inline void endDataAccess(CFbsBitmap *bitmap)
   179     {
   183     {
       
   184         heapRefCount--;
       
   185 
   180         if (symbianVersion == QSysInfo::SV_9_2) {
   186         if (symbianVersion == QSysInfo::SV_9_2) {
   181             if (!heapWasLocked)
   187             if (heapRefCount == 0)
   182                 qt_symbianFbsClient()->unlockHeap();
   188                 qt_symbianFbsClient()->unlockHeap();
   183         } else {
   189         } else {
   184             bitmap->UnlockHeap(ETrue);
   190             bitmap->UnlockHeap(ETrue);
   185         }
   191         }
   186     }
   192     }
   187 };
   193 };
       
   194 
       
   195 int QSymbianBitmapDataAccess::heapRefCount = 0;
   188 
   196 
   189 
   197 
   190 #define UPDATE_BUFFER()     \
   198 #define UPDATE_BUFFER()     \
   191     {                       \
   199     {                       \
   192     beginDataAccess();      \
   200     beginDataAccess();      \