plugin/qlibrary.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11static QBasicMutex qt_library_mutex; -
12static long qt_find_pattern(const char *s, ulong s_len, -
13 const char *pattern, ulong p_len) -
14{ -
15 if (! s || ! pattern || p_len > s_len) return -1;
never executed: return -1;
partially evaluated: ! s
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:227
partially evaluated: ! pattern
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:227
partially evaluated: p_len > s_len
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:227
0-227
16 ulong i, hs = 0, hp = 0, delta = s_len - p_len; -
17 -
18 for (i = 0; i < p_len; ++i) {
evaluated: i < p_len
TRUEFALSE
yes
Evaluation Count:2724
yes
Evaluation Count:227
227-2724
19 hs += s[delta + i]; -
20 hp += pattern[i]; -
21 }
executed: }
Execution Count:2724
2724
22 i = delta; -
23 for (;;) { -
24 if (hs == hp && qstrncmp(s + i, pattern, p_len) == 0)
evaluated: hs == hp
TRUEFALSE
yes
Evaluation Count:236
yes
Evaluation Count:54628
evaluated: qstrncmp(s + i, pattern, p_len) == 0
TRUEFALSE
yes
Evaluation Count:227
yes
Evaluation Count:9
9-54628
25 return i;
executed: return i;
Execution Count:227
227
26 if (i == 0)
partially evaluated: i == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:54637
0-54637
27 break;
never executed: break;
0
28 --i; -
29 hs -= s[i + p_len]; -
30 hs += s[i]; -
31 }
executed: }
Execution Count:54637
54637
32 -
33 return -1;
never executed: return -1;
0
34} -
35static bool qt_unix_query(const QString &library, QLibraryPrivate *lib) -
36{ -
37 QFile file(library); -
38 if (!file.open(QIODevice::ReadOnly)) {
partially evaluated: !file.open(QIODevice::ReadOnly)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:486
0-486
39 if (lib)
never evaluated: lib
0
40 lib->errorString = file.errorString();
never executed: lib->errorString = file.errorString();
0
41 if (qt_debug_component()) {
never evaluated: qt_debug_component()
0
42 QMessageLogger("plugin/qlibrary.cpp", 240, __PRETTY_FUNCTION__).warning("%s: %s", (const char*) QFile::encodeName(library), -
43 QString(qt_error_string((*__errno_location ()))).toLocal8Bit().constData()); -
44 }
never executed: }
0
45 return false;
never executed: return false;
0
46 } -
47 -
48 QByteArray data; -
49 const char *filedata = 0; -
50 ulong fdlen = file.size(); -
51 filedata = (char *) file.map(0, fdlen); -
52 if (filedata == 0) {
partially evaluated: filedata == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:486
0-486
53 -
54 data = file.readAll(); -
55 filedata = data.constData(); -
56 fdlen = data.size(); -
57 }
never executed: }
0
58 -
59 -
60 -
61 -
62 bool hasMetaData = false; -
63 long pos = 0; -
64 const char pattern[] = "QTMETADATA "; -
65 const ulong plen = qstrlen(pattern); -
66 -
67 int r = QElfParser().parse(filedata, fdlen, library, lib, &pos, &fdlen); -
68 if (r == QElfParser::Corrupt || r == QElfParser::NotElf) {
evaluated: r == QElfParser::Corrupt
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:483
evaluated: r == QElfParser::NotElf
TRUEFALSE
yes
Evaluation Count:255
yes
Evaluation Count:228
3-483
69 if (lib && qt_debug_component()) {
partially evaluated: lib
TRUEFALSE
yes
Evaluation Count:258
no
Evaluation Count:0
partially evaluated: qt_debug_component()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:258
0-258
70 QMessageLogger("plugin/qlibrary.cpp", 268, __PRETTY_FUNCTION__).warning("QElfParser: %s",QString(lib->errorString).toLocal8Bit().constData()); -
71 }
never executed: }
0
72 return false;
executed: return false;
Execution Count:258
258
73 } else if (r == QElfParser::QtMetaDataSection) {
evaluated: r == QElfParser::QtMetaDataSection
TRUEFALSE
yes
Evaluation Count:227
yes
Evaluation Count:1
1-227
74 long rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen); -
75 if (rel < 0)
partially evaluated: rel < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:227
0-227
76 pos = -1;
never executed: pos = -1;
0
77 else -
78 pos += rel;
executed: pos += rel;
Execution Count:227
227
79 hasMetaData = true; -
80 }
executed: }
Execution Count:227
227
81 -
82 -
83 -
84 -
85 -
86 -
87 bool ret = false; -
88 -
89 if (pos >= 0) {
partially evaluated: pos >= 0
TRUEFALSE
yes
Evaluation Count:228
no
Evaluation Count:0
0-228
90 if (hasMetaData) {
evaluated: hasMetaData
TRUEFALSE
yes
Evaluation Count:227
yes
Evaluation Count:1
1-227
91 const char *data = filedata + pos; -
92 QJsonDocument doc = QLibraryPrivate::fromRawMetaData(data); -
93 lib->metaData = doc.object(); -
94 if (qt_debug_component())
partially evaluated: qt_debug_component()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:227
0-227
95 QMessageLogger("plugin/qlibrary.cpp", 293, __PRETTY_FUNCTION__).warning("Found metadata in lib %s, metadata=\n%s\n", 0
96 library.toLocal8Bit().constData(), doc.toJson().constData());
never executed: QMessageLogger("plugin/qlibrary.cpp", 293, __PRETTY_FUNCTION__).warning("Found metadata in lib %s, metadata=\n%s\n", library.toLocal8Bit().constData(), doc.toJson().constData());
0
97 ret = !doc.isNull(); -
98 }
executed: }
Execution Count:227
227
99 }
executed: }
Execution Count:228
228
100 -
101 if (!ret && lib)
evaluated: !ret
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:227
partially evaluated: lib
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-227
102 lib->errorString = QLibrary::tr("Plugin verification data mismatch in '%1'").arg(library);
executed: lib->errorString = QLibrary::tr("Plugin verification data mismatch in '%1'").arg(library);
Execution Count:1
1
103 file.close(); -
104 return ret;
executed: return ret;
Execution Count:228
228
105} -
106 -
107 -
108 -
109static void installCoverageTool(QLibraryPrivate *libPrivate) -
110{ -
111 int ret = __coveragescanner_register_library(libPrivate->fileName.toLocal8Bit()); -
112 -
113 if (qt_debug_component()) {
partially evaluated: qt_debug_component()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:253
0-253
114 if (ret >= 0) {
never evaluated: ret >= 0
0
115 QMessageLogger("plugin/qlibrary.cpp", 327, __PRETTY_FUNCTION__).debug("%s: coverage data for %s registered", -
116 __PRETTY_FUNCTION__, -
117 QString(libPrivate->fileName).toLocal8Bit().constData()); -
118 } else {
never executed: }
0
119 QMessageLogger("plugin/qlibrary.cpp", 331, __PRETTY_FUNCTION__).warning("%s: could not register %s: error %d; coverage data may be incomplete", -
120 __PRETTY_FUNCTION__, -
121 QString(libPrivate->fileName).toLocal8Bit().constData(), -
122 ret); -
123 }
never executed: }
0
124 } -
125 -
126 -
127 -
128}
executed: }
Execution Count:253
253
129 -
130typedef QMap<QString, QLibraryPrivate*> LibraryMap; -
131 -
132struct LibraryData { -
133 LibraryMap libraryMap; -
134 QSet<QLibraryPrivate*> loadedLibs; -
135}; -
136 -
137static LibraryData *libraryData() { static QGlobalStatic<LibraryData > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { LibraryData *x = new LibraryData; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<LibraryData > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:4922
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:44
no
Evaluation Count:0
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:4966
0-4966
138 -
139static LibraryMap *libraryMap() -
140{ -
141 LibraryData *data = libraryData(); -
142 return data ? &data->libraryMap : 0;
executed: return data ? &data->libraryMap : 0;
Execution Count:3770
3770
143} -
144 -
145QLibraryPrivate::QLibraryPrivate(const QString &canonicalFileName, const QString &version) -
146 : pHnd(0), fileName(canonicalFileName), fullVersion(version), instance(0), -
147 loadHints(0), -
148 libraryRefCount(1), libraryUnloadCount(0), pluginState(MightBeAPlugin) -
149{ libraryMap()->insert(canonicalFileName, this); }
executed: }
Execution Count:608
608
150 -
151QLibraryPrivate *QLibraryPrivate::findOrCreate(const QString &fileName, const QString &version) -
152{ -
153 QMutexLocker locker(&qt_library_mutex); -
154 if (QLibraryPrivate *lib = libraryMap()->value(fileName)) {
evaluated: QLibraryPrivate *lib = libraryMap()->value(fileName)
TRUEFALSE
yes
Evaluation Count:147
yes
Evaluation Count:608
147-608
155 lib->libraryRefCount.ref(); -
156 return lib;
executed: return lib;
Execution Count:147
147
157 } -
158 -
159 return new QLibraryPrivate(fileName, version);
executed: return new QLibraryPrivate(fileName, version);
Execution Count:608
608
160} -
161 -
162QLibraryPrivate::~QLibraryPrivate() -
163{ -
164 LibraryMap * const map = libraryMap(); -
165 if (map) {
partially evaluated: map
TRUEFALSE
yes
Evaluation Count:2407
no
Evaluation Count:0
0-2407
166 QLibraryPrivate *that = map->take(fileName); -
167 qt_noop(); -
168 (void)that;; -
169 }
executed: }
Execution Count:2407
2407
170}
executed: }
Execution Count:2407
2407
171 -
172QFunctionPointer QLibraryPrivate::resolve(const char *symbol) -
173{ -
174 if (!pHnd)
partially evaluated: !pHnd
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3475
0-3475
175 return 0;
never executed: return 0;
0
176 return resolve_sys(symbol);
executed: return resolve_sys(symbol);
Execution Count:3475
3475
177} -
178 -
179 -
180bool QLibraryPrivate::load() -
181{ -
182 libraryUnloadCount.ref(); -
183 if (pHnd)
evaluated: pHnd
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:260
105-260
184 return true;
executed: return true;
Execution Count:105
105
185 if (fileName.isEmpty())
partially evaluated: fileName.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:260
0-260
186 return false;
never executed: return false;
0
187 -
188 bool ret = load_sys(); -
189 if (qt_debug_component())
partially evaluated: qt_debug_component()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:260
0-260
190 QMessageLogger("plugin/qlibrary.cpp", 402, __PRETTY_FUNCTION__).debug() << "loaded library" << fileName;
never executed: QMessageLogger("plugin/qlibrary.cpp", 402, __PRETTY_FUNCTION__).debug() << "loaded library" << fileName;
0
191 if (ret) {
evaluated: ret
TRUEFALSE
yes
Evaluation Count:253
yes
Evaluation Count:7
7-253
192 -
193 -
194 if (LibraryData *lib = libraryData()) {
partially evaluated: LibraryData *lib = libraryData()
TRUEFALSE
yes
Evaluation Count:253
no
Evaluation Count:0
0-253
195 lib->loadedLibs += this; -
196 libraryRefCount.ref(); -
197 }
executed: }
Execution Count:253
253
198 -
199 installCoverageTool(this); -
200 }
executed: }
Execution Count:253
253
201 -
202 return ret;
executed: return ret;
Execution Count:260
260
203} -
204 -
205bool QLibraryPrivate::unload() -
206{ -
207 if (!pHnd)
evaluated: !pHnd
TRUEFALSE
yes
Evaluation Count:1201
yes
Evaluation Count:945
945-1201
208 return false;
executed: return false;
Execution Count:1201
1201
209 if (!libraryUnloadCount.deref()) {
evaluated: !libraryUnloadCount.deref()
TRUEFALSE
yes
Evaluation Count:943
yes
Evaluation Count:2
2-943
210 delete inst.data(); -
211 if (unload_sys()) {
partially evaluated: unload_sys()
TRUEFALSE
yes
Evaluation Count:943
no
Evaluation Count:0
0-943
212 if (qt_debug_component())
partially evaluated: qt_debug_component()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:943
0-943
213 QMessageLogger("plugin/qlibrary.cpp", 425, __PRETTY_FUNCTION__).warning() << "QLibraryPrivate::unload succeeded on" << fileName;
never executed: QMessageLogger("plugin/qlibrary.cpp", 425, __PRETTY_FUNCTION__).warning() << "QLibraryPrivate::unload succeeded on" << fileName;
0
214 -
215 -
216 if (LibraryData *lib = libraryData()) {
partially evaluated: LibraryData *lib = libraryData()
TRUEFALSE
yes
Evaluation Count:943
no
Evaluation Count:0
0-943
217 if (lib->loadedLibs.remove(this))
partially evaluated: lib->loadedLibs.remove(this)
TRUEFALSE
yes
Evaluation Count:943
no
Evaluation Count:0
0-943
218 libraryRefCount.deref();
executed: libraryRefCount.deref();
Execution Count:943
943
219 }
executed: }
Execution Count:943
943
220 pHnd = 0; -
221 instance = 0; -
222 }
executed: }
Execution Count:943
943
223 }
executed: }
Execution Count:943
943
224 -
225 return (pHnd == 0);
executed: return (pHnd == 0);
Execution Count:945
945
226} -
227 -
228void QLibraryPrivate::release() -
229{ -
230 QMutexLocker locker(&qt_library_mutex); -
231 if (!libraryRefCount.deref())
evaluated: !libraryRefCount.deref()
TRUEFALSE
yes
Evaluation Count:2407
yes
Evaluation Count:189
189-2407
232 delete this;
executed: delete this;
Execution Count:2407
2407
233}
executed: }
Execution Count:2596
2596
234 -
235bool QLibraryPrivate::loadPlugin() -
236{ -
237 if (instance) {
evaluated: instance
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:167
1-167
238 libraryUnloadCount.ref(); -
239 return true;
executed: return true;
Execution Count:1
1
240 } -
241 if (pluginState == IsNotAPlugin)
partially evaluated: pluginState == IsNotAPlugin
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:167
0-167
242 return false;
never executed: return false;
0
243 if (load()) {
evaluated: load()
TRUEFALSE
yes
Evaluation Count:166
yes
Evaluation Count:1
1-166
244 instance = (QtPluginInstanceFunction)resolve("qt_plugin_instance"); -
245 return instance;
executed: return instance;
Execution Count:166
166
246 } -
247 if (qt_debug_component())
partially evaluated: qt_debug_component()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
248 QMessageLogger("plugin/qlibrary.cpp", 460, __PRETTY_FUNCTION__).warning() << "QLibraryPrivate::loadPlugin failed on" << fileName << ":" << errorString;
never executed: QMessageLogger("plugin/qlibrary.cpp", 460, __PRETTY_FUNCTION__).warning() << "QLibraryPrivate::loadPlugin failed on" << fileName << ":" << errorString;
0
249 pluginState = IsNotAPlugin; -
250 return false;
executed: return false;
Execution Count:1
1
251} -
252bool QLibrary::isLibrary(const QString &fileName) -
253{ -
254 -
255 -
256 -
257 QString completeSuffix = QFileInfo(fileName).completeSuffix(); -
258 if (completeSuffix.isEmpty())
partially evaluated: completeSuffix.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
259 return false;
never executed: return false;
0
260 QStringList suffixes = completeSuffix.split(QLatin1Char('.')); -
261 QStringList validSuffixList; -
262 validSuffixList << QLatin1String("so"); -
263 int suffix; -
264 int suffixPos = -1; -
265 for (suffix = 0; suffix < validSuffixList.count() && suffixPos == -1; ++suffix)
evaluated: suffix < validSuffixList.count()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:16
partially evaluated: suffixPos == -1
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
266 suffixPos = suffixes.indexOf(validSuffixList.at(suffix));
executed: suffixPos = suffixes.indexOf(validSuffixList.at(suffix));
Execution Count:16
16
267 -
268 bool valid = suffixPos != -1; -
269 for (int i = suffixPos + 1; i < suffixes.count() && valid; ++i)
evaluated: i < suffixes.count()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
evaluated: valid
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
6-14
270 if (i != suffixPos)
partially evaluated: i != suffixPos
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
271 suffixes.at(i).toInt(&valid);
executed: suffixes.at(i).toInt(&valid);
Execution Count:6
6
272 return valid;
executed: return valid;
Execution Count:16
16
273 -
274 -
275 -
276} -
277typedef const char * (*QtPluginQueryVerificationDataFunction)(); -
278 -
279bool qt_get_metadata(QtPluginQueryVerificationDataFunction pfn, QLibraryPrivate *priv, bool *exceptionThrown) -
280{ -
281 *exceptionThrown = false; -
282 const char *szData = 0; -
283 if (!pfn)
never evaluated: !pfn
0
284 return false;
never executed: return false;
0
285 -
286 -
287 -
288 -
289 -
290 szData = pfn(); -
291 -
292 if (!szData)
never evaluated: !szData
0
293 return false;
never executed: return false;
0
294 QJsonDocument doc = QLibraryPrivate::fromRawMetaData(szData); -
295 if (doc.isNull())
never evaluated: doc.isNull()
0
296 return false;
never executed: return false;
0
297 priv->metaData = doc.object(); -
298 return true;
never executed: return true;
0
299} -
300 -
301bool QLibraryPrivate::isPlugin() -
302{ -
303 if (pluginState == MightBeAPlugin)
evaluated: pluginState == MightBeAPlugin
TRUEFALSE
yes
Evaluation Count:467
yes
Evaluation Count:52
52-467
304 updatePluginState();
executed: updatePluginState();
Execution Count:467
467
305 -
306 return pluginState == IsAPlugin;
executed: return pluginState == IsAPlugin;
Execution Count:519
519
307} -
308 -
309void QLibraryPrivate::updatePluginState() -
310{ -
311 errorString.clear(); -
312 if (pluginState != MightBeAPlugin)
evaluated: pluginState != MightBeAPlugin
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:486
2-486
313 return;
executed: return;
Execution Count:2
2
314 -
315 bool success = false; -
316 -
317 -
318 if (fileName.endsWith(QLatin1String(".debug"))) {
partially evaluated: fileName.endsWith(QLatin1String(".debug"))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:486
0-486
319 -
320 -
321 -
322 -
323 -
324 -
325 errorString = QLibrary::tr("The shared library was not found."); -
326 pluginState = IsNotAPlugin; -
327 return;
never executed: return;
0
328 } -
329 -
330 -
331 -
332 if (!pHnd) {
partially evaluated: !pHnd
TRUEFALSE
yes
Evaluation Count:486
no
Evaluation Count:0
0-486
333 -
334 success = qt_unix_query(fileName, this); -
335 } else
executed: }
Execution Count:486
486
336 -
337 { -
338 bool retryLoadLibrary = false; -
339 do { -
340 bool temporary_load = false; -
341 -
342 -
343 -
344 if (!pHnd) {
never evaluated: !pHnd
0
345 -
346 -
347 -
348 -
349 -
350 -
351 -
352 temporary_load = load_sys(); -
353 -
354 }
never executed: }
0
355 QtPluginQueryVerificationDataFunction getMetaData = __null; -
356 -
357 bool exceptionThrown = false; -
358 bool ret = false; -
359 { -
360 getMetaData = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_metadata"); -
361 } -
362 -
363 if (getMetaData)
never evaluated: getMetaData
0
364 ret = qt_get_metadata(getMetaData, this, &exceptionThrown);
never executed: ret = qt_get_metadata(getMetaData, this, &exceptionThrown);
0
365 -
366 if (!exceptionThrown) {
never evaluated: !exceptionThrown
0
367 if (!ret) {
never evaluated: !ret
0
368 if (temporary_load)
never evaluated: temporary_load
0
369 unload_sys();
never executed: unload_sys();
0
370 } else {
never executed: }
0
371 success = true; -
372 }
never executed: }
0
373 retryLoadLibrary = false; -
374 }
never executed: }
0
375 } while (retryLoadLibrary);
never evaluated: retryLoadLibrary
never executed: }
0
376 -
377 }
never executed: }
0
378 -
379 if (!success) {
evaluated: !success
TRUEFALSE
yes
Evaluation Count:259
yes
Evaluation Count:227
227-259
380 if (errorString.isEmpty()){
partially evaluated: errorString.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:259
0-259
381 if (fileName.isEmpty())
never evaluated: fileName.isEmpty()
0
382 errorString = QLibrary::tr("The shared library was not found.");
never executed: errorString = QLibrary::tr("The shared library was not found.");
0
383 else -
384 errorString = QLibrary::tr("The file '%1' is not a valid Qt plugin.").arg(fileName);
never executed: errorString = QLibrary::tr("The file '%1' is not a valid Qt plugin.").arg(fileName);
0
385 } -
386 pluginState = IsNotAPlugin; -
387 return;
executed: return;
Execution Count:259
259
388 } -
389 -
390 pluginState = IsNotAPlugin; -
391 -
392 uint qt_version = (uint)metaData.value(QLatin1String("version")).toDouble(); -
393 bool debug = metaData.value(QLatin1String("debug")).toBool(); -
394 if ((qt_version & 0x00ff00) > (0x050002 & 0x00ff00) || (qt_version & 0xff0000) != (0x050002 & 0xff0000)) {
partially evaluated: (qt_version & 0x00ff00) > (0x050002 & 0x00ff00)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:227
partially evaluated: (qt_version & 0xff0000) != (0x050002 & 0xff0000)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:227
0-227
395 if (qt_debug_component()) {
never evaluated: qt_debug_component()
0
396 QMessageLogger("plugin/qlibrary.cpp", 707, __PRETTY_FUNCTION__).warning("In %s:\n" -
397 " Plugin uses incompatible Qt library (%d.%d.%d) [%s]", -
398 (const char*) QFile::encodeName(fileName), -
399 (qt_version&0xff0000) >> 16, (qt_version&0xff00) >> 8, qt_version&0xff, -
400 debug ? "debug" : "release"); -
401 }
never executed: }
0
402 errorString = QLibrary::tr("The plugin '%1' uses incompatible Qt library. (%2.%3.%4) [%5]") -
403 .arg(fileName) -
404 .arg((qt_version&0xff0000) >> 16) -
405 .arg((qt_version&0xff00) >> 8) -
406 .arg(qt_version&0xff) -
407 .arg(debug ? QLatin1String("debug") : QLatin1String("release")); -
408 -
409 -
410 -
411 -
412 -
413 -
414 } else {
never executed: }
0
415 pluginState = IsAPlugin; -
416 }
executed: }
Execution Count:227
227
417} -
418bool QLibrary::load() -
419{ -
420 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:198
1-198
421 return false;
executed: return false;
Execution Count:1
1
422 if (did_load)
partially evaluated: did_load
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:198
0-198
423 return d->pHnd;
never executed: return d->pHnd;
0
424 did_load = true; -
425 return d->load();
executed: return d->load();
Execution Count:198
198
426} -
427bool QLibrary::unload() -
428{ -
429 if (did_load) {
evaluated: did_load
TRUEFALSE
yes
Evaluation Count:221
yes
Evaluation Count:26
26-221
430 did_load = false; -
431 return d->unload();
executed: return d->unload();
Execution Count:221
221
432 } -
433 return false;
executed: return false;
Execution Count:26
26
434} -
435 -
436 -
437 -
438 -
439 -
440 -
441bool QLibrary::isLoaded() const -
442{ -
443 return d && d->pHnd;
executed: return d && d->pHnd;
Execution Count:7621
7621
444} -
445 -
446 -
447 -
448 -
449 -
450QLibrary::QLibrary(QObject *parent) -
451 :QObject(parent), d(0), did_load(false) -
452{ -
453}
executed: }
Execution Count:51
51
454QLibrary::QLibrary(const QString& fileName, QObject *parent) -
455 :QObject(parent), d(0), did_load(false) -
456{ -
457 setFileName(fileName); -
458}
executed: }
Execution Count:31
31
459QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent) -
460 :QObject(parent), d(0), did_load(false) -
461{ -
462 setFileNameAndVersion(fileName, verNum); -
463}
executed: }
Execution Count:125
125
464QLibrary::QLibrary(const QString& fileName, const QString &version, QObject *parent) -
465 :QObject(parent), d(0), did_load(false) -
466{ -
467 setFileNameAndVersion(fileName, version); -
468}
never executed: }
0
469QLibrary::~QLibrary() -
470{ -
471 if (d)
evaluated: d
TRUEFALSE
yes
Evaluation Count:376
yes
Evaluation Count:1
1-376
472 d->release();
executed: d->release();
Execution Count:376
376
473}
executed: }
Execution Count:377
377
474void QLibrary::setFileName(const QString &fileName) -
475{ -
476 QLibrary::LoadHints lh; -
477 if (d) {
evaluated: d
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:60
3-60
478 lh = d->loadHints; -
479 d->release(); -
480 d = 0; -
481 did_load = false; -
482 }
executed: }
Execution Count:3
3
483 d = QLibraryPrivate::findOrCreate(fileName); -
484 d->loadHints = lh; -
485}
executed: }
Execution Count:63
63
486 -
487QString QLibrary::fileName() const -
488{ -
489 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-26
490 return d->qualifiedFileName.isEmpty() ? d->fileName : d->qualifiedFileName;
executed: return d->qualifiedFileName.isEmpty() ? d->fileName : d->qualifiedFileName;
Execution Count:26
26
491 return QString();
never executed: return QString();
0
492} -
493void QLibrary::setFileNameAndVersion(const QString &fileName, int verNum) -
494{ -
495 QLibrary::LoadHints lh; -
496 if (d) {
evaluated: d
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:125
25-125
497 lh = d->loadHints; -
498 d->release(); -
499 d = 0; -
500 did_load = false; -
501 }
executed: }
Execution Count:25
25
502 d = QLibraryPrivate::findOrCreate(fileName, verNum >= 0 ? QString::number(verNum) : QString()); -
503 d->loadHints = lh; -
504}
executed: }
Execution Count:150
150
505void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &version) -
506{ -
507 QLibrary::LoadHints lh; -
508 if (d) {
partially evaluated: d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
509 lh = d->loadHints; -
510 d->release(); -
511 d = 0; -
512 did_load = false; -
513 }
never executed: }
0
514 d = QLibraryPrivate::findOrCreate(fileName, version); -
515 d->loadHints = lh; -
516}
executed: }
Execution Count:18
18
517QFunctionPointer QLibrary::resolve(const char *symbol) -
518{ -
519 if (!isLoaded() && !load())
evaluated: !isLoaded()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:3299
evaluated: !load()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-3299
520 return 0;
executed: return 0;
Execution Count:1
1
521 return d->resolve(symbol);
executed: return d->resolve(symbol);
Execution Count:3309
3309
522} -
523QFunctionPointer QLibrary::resolve(const QString &fileName, const char *symbol) -
524{ -
525 QLibrary library(fileName); -
526 return library.resolve(symbol);
never executed: return library.resolve(symbol);
0
527} -
528QFunctionPointer QLibrary::resolve(const QString &fileName, int verNum, const char *symbol) -
529{ -
530 QLibrary library(fileName, verNum); -
531 return library.resolve(symbol);
executed: return library.resolve(symbol);
Execution Count:11
11
532} -
533QFunctionPointer QLibrary::resolve(const QString &fileName, const QString &version, const char *symbol) -
534{ -
535 QLibrary library(fileName, version); -
536 return library.resolve(symbol);
never executed: return library.resolve(symbol);
0
537} -
538 -
539 -
540 -
541 -
542 -
543 -
544 -
545QString QLibrary::errorString() const -
546{ -
547 return (!d || d->errorString.isEmpty()) ? tr("Unknown error") : d->errorString;
executed: return (!d || d->errorString.isEmpty()) ? tr("Unknown error") : d->errorString;
Execution Count:21
21
548} -
549void QLibrary::setLoadHints(LoadHints hints) -
550{ -
551 if (!d) {
partially evaluated: !d
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
552 d = QLibraryPrivate::findOrCreate(QString()); -
553 d->errorString.clear(); -
554 }
executed: }
Execution Count:3
3
555 d->loadHints = hints; -
556}
executed: }
Execution Count:3
3
557 -
558QLibrary::LoadHints QLibrary::loadHints() const -
559{ -
560 return d ? d->loadHints : (QLibrary::LoadHints)0;
executed: return d ? d->loadHints : (QLibrary::LoadHints)0;
Execution Count:6
6
561} -
562 -
563 -
564bool qt_debug_component() -
565{ -
566 static int debug_env = -1; -
567 if (debug_env == -1)
evaluated: debug_env == -1
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:2896
44-2896
568 debug_env = ::qgetenv("QT_DEBUG_PLUGINS").toInt();
executed: debug_env = ::qgetenv("QT_DEBUG_PLUGINS").toInt();
Execution Count:44
44
569 -
570 return debug_env != 0;
executed: return debug_env != 0;
Execution Count:2940
2940
571} -
572 -
573 -
574 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial