| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | static QBasicMutex destructorsMutex; | - |
| 8 | typedef QVector<void (*)(void *)> DestructorMap; | - |
| 9 | static DestructorMap *destructors() { static QGlobalStatic<DestructorMap > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { DestructorMap *x = new DestructorMap; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<DestructorMap > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; executed: return thisGlobalStatic.pointer.load();Execution Count:3363 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)| no Evaluation Count:0 | yes Evaluation Count:12 |
evaluated: !thisGlobalStatic.pointer.load()| yes Evaluation Count:12 | yes Evaluation Count:3352 |
partially evaluated: !thisGlobalStatic.destroyed| yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-3363 |
| 10 | | - |
| 11 | QThreadStorageData::QThreadStorageData(void (*func)(void *)) | - |
| 12 | { | - |
| 13 | QMutexLocker locker(&destructorsMutex); | - |
| 14 | DestructorMap *destr = destructors(); | - |
| 15 | if (!destr) { partially evaluated: !destr| no Evaluation Count:0 | yes Evaluation Count:370 |
| 0-370 |
| 16 | QThreadData *data = QThreadData::current(); | - |
| 17 | id = data->tls.count(); | - |
| 18 | if(false)QMessageLogger("thread/qthreadstorage.cpp", 94, __PRETTY_FUNCTION__).debug("QThreadStorageData: Allocated id %d, destructor %p cannot be stored", id, func); never executed: QMessageLogger("thread/qthreadstorage.cpp", 94, __PRETTY_FUNCTION__).debug("QThreadStorageData: Allocated id %d, destructor %p cannot be stored", id, func); | 0 |
| 19 | return; | 0 |
| 20 | } | - |
| 21 | for (id = 0; id < destr->count(); id++) { evaluated: id < destr->count()| yes Evaluation Count:585 | yes Evaluation Count:359 |
| 359-585 |
| 22 | if (destr->at(id) == 0) evaluated: destr->at(id) == 0| yes Evaluation Count:11 | yes Evaluation Count:574 |
| 11-574 |
| 23 | break; executed: break;Execution Count:11 | 11 |
| 24 | } executed: }Execution Count:574 | 574 |
| 25 | if (id == destr->count()) { evaluated: id == destr->count()| yes Evaluation Count:359 | yes Evaluation Count:11 |
| 11-359 |
| 26 | destr->append(func); | - |
| 27 | } else { executed: }Execution Count:359 | 359 |
| 28 | (*destr)[id] = func; | - |
| 29 | } executed: }Execution Count:11 | 11 |
| 30 | if(false)QMessageLogger("thread/qthreadstorage.cpp", 106, __PRETTY_FUNCTION__).debug("QThreadStorageData: Allocated id %d, destructor %p", id, func); partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:370 |
never executed: QMessageLogger("thread/qthreadstorage.cpp", 106, __PRETTY_FUNCTION__).debug("QThreadStorageData: Allocated id %d, destructor %p", id, func); | 0-370 |
| 31 | } executed: }Execution Count:370 | 370 |
| 32 | | - |
| 33 | QThreadStorageData::~QThreadStorageData() | - |
| 34 | { | - |
| 35 | if(false)QMessageLogger("thread/qthreadstorage.cpp", 111, __PRETTY_FUNCTION__).debug("QThreadStorageData: Released id %d", id); never executed: QMessageLogger("thread/qthreadstorage.cpp", 111, __PRETTY_FUNCTION__).debug("QThreadStorageData: Released id %d", id); partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:368 |
| 0-368 |
| 36 | QMutexLocker locker(&destructorsMutex); | - |
| 37 | if (destructors()) partially evaluated: destructors()| yes Evaluation Count:368 | no Evaluation Count:0 |
| 0-368 |
| 38 | (*destructors())[id] = 0; executed: (*destructors())[id] = 0;Execution Count:368 | 368 |
| 39 | } executed: }Execution Count:368 | 368 |
| 40 | | - |
| 41 | void **QThreadStorageData::get() const | - |
| 42 | { | - |
| 43 | QThreadData *data = QThreadData::current(); | - |
| 44 | if (!data) { partially evaluated: !data| no Evaluation Count:0 | yes Evaluation Count:7409468 |
| 0-7409468 |
| 45 | QMessageLogger("thread/qthreadstorage.cpp", 121, __PRETTY_FUNCTION__).warning("QThreadStorage::get: QThreadStorage can only be used with threads started with QThread"); | - |
| 46 | return 0; never executed: return 0; | 0 |
| 47 | } | - |
| 48 | QVector<void *> &tls = data->tls; | - |
| 49 | if (tls.size() <= id) evaluated: tls.size() <= id| yes Evaluation Count:1574 | yes Evaluation Count:7407895 |
| 1574-7407895 |
| 50 | tls.resize(id + 1); executed: tls.resize(id + 1);Execution Count:1573 | 1573 |
| 51 | void **v = &tls[id]; | - |
| 52 | | - |
| 53 | if(false)QMessageLogger("thread/qthreadstorage.cpp", 129, __PRETTY_FUNCTION__).debug("QThreadStorageData: Returning storage %d, data %p, for thread %p", partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:7409469 |
| 0-7409469 |
| 54 | id, | 0 |
| 55 | *v, | 0 |
| 56 | data->thread); never executed: QMessageLogger("thread/qthreadstorage.cpp", 129, __PRETTY_FUNCTION__).debug("QThreadStorageData: Returning storage %d, data %p, for thread %p", id, *v, data->thread); | 0 |
| 57 | | - |
| 58 | return *v ? v : 0; executed: return *v ? v : 0;Execution Count:7409469 | 7409469 |
| 59 | } | - |
| 60 | | - |
| 61 | void **QThreadStorageData::set(void *p) | - |
| 62 | { | - |
| 63 | QThreadData *data = QThreadData::current(); | - |
| 64 | if (!data) { partially evaluated: !data| no Evaluation Count:0 | yes Evaluation Count:2467 |
| 0-2467 |
| 65 | QMessageLogger("thread/qthreadstorage.cpp", 141, __PRETTY_FUNCTION__).warning("QThreadStorage::set: QThreadStorage can only be used with threads started with QThread"); | - |
| 66 | return 0; never executed: return 0; | 0 |
| 67 | } | - |
| 68 | QVector<void *> &tls = data->tls; | - |
| 69 | if (tls.size() <= id) evaluated: tls.size() <= id| yes Evaluation Count:6 | yes Evaluation Count:2462 |
| 6-2462 |
| 70 | tls.resize(id + 1); executed: tls.resize(id + 1);Execution Count:6 | 6 |
| 71 | | - |
| 72 | void *&value = tls[id]; | - |
| 73 | | - |
| 74 | if (value != 0) { evaluated: value != 0| yes Evaluation Count:198 | yes Evaluation Count:2270 |
| 198-2270 |
| 75 | if(false)QMessageLogger("thread/qthreadstorage.cpp", 151, __PRETTY_FUNCTION__).debug("QThreadStorageData: Deleting previous storage %d, data %p, for thread %p", partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:198 |
| 0-198 |
| 76 | id, | 0 |
| 77 | value, | 0 |
| 78 | data->thread); never executed: QMessageLogger("thread/qthreadstorage.cpp", 151, __PRETTY_FUNCTION__).debug("QThreadStorageData: Deleting previous storage %d, data %p, for thread %p", id, value, data->thread); | 0 |
| 79 | | - |
| 80 | QMutexLocker locker(&destructorsMutex); | - |
| 81 | DestructorMap *destr = destructors(); | - |
| 82 | void (*destructor)(void *) = destr ? destr->value(id) : 0; partially evaluated: destr| yes Evaluation Count:198 | no Evaluation Count:0 |
| 0-198 |
| 83 | locker.unlock(); | - |
| 84 | | - |
| 85 | void *q = value; | - |
| 86 | value = 0; | - |
| 87 | | - |
| 88 | if (destructor) partially evaluated: destructor| yes Evaluation Count:198 | no Evaluation Count:0 |
| 0-198 |
| 89 | destructor(q); executed: destructor(q);Execution Count:198 | 198 |
| 90 | } executed: }Execution Count:198 | 198 |
| 91 | | - |
| 92 | | - |
| 93 | value = p; | - |
| 94 | if(false)QMessageLogger("thread/qthreadstorage.cpp", 170, __PRETTY_FUNCTION__).debug("QThreadStorageData: Set storage %d for thread %p to %p", id, data->thread, p); never executed: QMessageLogger("thread/qthreadstorage.cpp", 170, __PRETTY_FUNCTION__).debug("QThreadStorageData: Set storage %d for thread %p to %p", id, data->thread, p); partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:2468 |
| 0-2468 |
| 95 | return &value; executed: return &value;Execution Count:2467 | 2467 |
| 96 | } | - |
| 97 | | - |
| 98 | void QThreadStorageData::finish(void **p) | - |
| 99 | { | - |
| 100 | QVector<void *> *tls = reinterpret_cast<QVector<void *> *>(p); | - |
| 101 | if (!tls || tls->isEmpty() || !destructors()) partially evaluated: !tls| no Evaluation Count:0 | yes Evaluation Count:1717849 |
evaluated: tls->isEmpty()| yes Evaluation Count:1716984 | yes Evaluation Count:871 |
partially evaluated: !destructors()| no Evaluation Count:0 | yes Evaluation Count:871 |
| 0-1717849 |
| 102 | return; executed: return;Execution Count:1716986 | 1716986 |
| 103 | | - |
| 104 | if(false)QMessageLogger("thread/qthreadstorage.cpp", 180, __PRETTY_FUNCTION__).debug("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread()); never executed: QMessageLogger("thread/qthreadstorage.cpp", 180, __PRETTY_FUNCTION__).debug("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread()); partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:871 |
| 0-871 |
| 105 | while (!tls->isEmpty()) { evaluated: !tls->isEmpty()| yes Evaluation Count:2506 | yes Evaluation Count:871 |
| 871-2506 |
| 106 | void *&value = tls->last(); | - |
| 107 | void *q = value; | - |
| 108 | value = 0; | - |
| 109 | int i = tls->size() - 1; | - |
| 110 | tls->resize(i); | - |
| 111 | | - |
| 112 | if (!q) { evaluated: !q| yes Evaluation Count:1317 | yes Evaluation Count:1188 |
| 1188-1317 |
| 113 | | - |
| 114 | continue; executed: continue;Execution Count:1317 | 1317 |
| 115 | } | - |
| 116 | | - |
| 117 | QMutexLocker locker(&destructorsMutex); | - |
| 118 | void (*destructor)(void *) = destructors()->value(i); | - |
| 119 | locker.unlock(); | - |
| 120 | | - |
| 121 | if (!destructor) { partially evaluated: !destructor| no Evaluation Count:0 | yes Evaluation Count:1189 |
| 0-1189 |
| 122 | if (QThread::currentThread()) never evaluated: QThread::currentThread() | 0 |
| 123 | QMessageLogger("thread/qthreadstorage.cpp", 199, __PRETTY_FUNCTION__).warning("QThreadStorage: Thread %p exited after QThreadStorage %d destroyed", | 0 |
| 124 | QThread::currentThread(), i); never executed: QMessageLogger("thread/qthreadstorage.cpp", 199, __PRETTY_FUNCTION__).warning("QThreadStorage: Thread %p exited after QThreadStorage %d destroyed", QThread::currentThread(), i); | 0 |
| 125 | continue; never executed: continue; | 0 |
| 126 | } | - |
| 127 | destructor(q); | - |
| 128 | | - |
| 129 | if (tls->size() > i) { evaluated: tls->size() > i| yes Evaluation Count:16 | yes Evaluation Count:1173 |
| 16-1173 |
| 130 | | - |
| 131 | (*tls)[i] = 0; | - |
| 132 | } executed: }Execution Count:16 | 16 |
| 133 | } executed: }Execution Count:1189 | 1189 |
| 134 | tls->clear(); | - |
| 135 | } executed: }Execution Count:871 | 871 |
| 136 | | - |
| 137 | | - |
| | |