Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/image/qpixmapcache.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    4040****************************************************************************/
    4141
     42
    4243#include "qpixmapcache.h"
    4344#include "qobject.h"
     
    195196    static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key);
    196197
     198
     199
     200
    197201private:
     202
    198203    int *keyArray;
    199204    int theid;
     
    233238  cache is in active use.
    234239
    235   When the last pixmap has been deleted from the cache, kill the
    236   timer so Qt won't keep the CPU from going into sleep mode.
    237 */
    238 void QPMCache::timerEvent(QTimerEvent *)
     240  When the last detached pixmap has been deleted from the cache, kill the
     241  timer so Qt won't keep the CPU from going into sleep mode. Currently
     242  the timer is not restarted when the pixmap becomes unused, but it does
     243  restart once something else is added (i.e. the cache space is actually needed).
     244
     245  Returns true if any were removed.
     246*/
     247bool QPMCache::flushDetachedPixmaps(bool nt)
    239248{
    240249    int mc = maxCost();
    241     bool nt = totalCost() == ps;
    242250    setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1);
    243251    setMaxCost(mc);
    244252    ps = totalCost();
    245253
     254
    246255    QHash<QString, QPixmapCache::Key>::iterator it = cacheKeys.begin();
    247256    while (it != cacheKeys.end()) {
     
    249258            releaseKey(it.value());
    250259            it = cacheKeys.erase(it);
     260
    251261        } else {
    252262            ++it;
     
    254264    }
    255265
    256     if (!size()) {
     266    return any;
     267}
     268
     269void QPMCache::timerEvent(QTimerEvent *)
     270{
     271    bool nt = totalCost() == ps;
     272    if (!flushDetachedPixmaps(nt)) {
    257273        killTimer(theid);
    258274        theid = 0;
    259275    } else if (nt != t) {
    260276        killTimer(theid);
    261         theid = startTimer(nt ? 10000 : 30000);
     277        theid = startTimer(nt ? );
    262278        t = nt;
    263279    }
    264280}
     281
    265282
    266283QPixmap *QPMCache::object(const QString &key) const
     
    306323        cacheKeys.insert(key, cacheKey);
    307324        if (!theid) {
    308             theid = startTimer(30000);
     325            theid = startTimer();
    309326            t = false;
    310327        }
     
    322339    if (success) {
    323340        if (!theid) {
    324             theid = startTimer(30000);
     341            theid = startTimer();
    325342            t = false;
    326343        }
     
    343360    if (success) {
    344361        if(!theid) {
    345             theid = startTimer(30000);
     362            theid = startTimer();
    346363            t = false;
    347364        }
     
    423440}
    424441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
    425456Q_GLOBAL_STATIC(QPMCache, pm_cache)
    426457
     
    634665}
    635666
     667
     668
     669
     670
     671
     672
     673
     674
     675
     676
     677
     678
     679
     680
     681
    636682QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.