OpenCoverage

qfileselector.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qfileselector.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6static const char env_override[] = "QT_NO_BUILTIN_SELECTORS";-
7-
8static const ushort selectorIndicator = '+';-
9-
10namespace { namespace Q_QGS_sharedData { typedef QFileSelectorSharedData Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qfileselectors - unknown status
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
executed 1 time by 1 test: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qfileselectors - unknown status
}
executed 1 time by 1 test: end of block
Executed by:
  • tst_qfileselectors - unknown status
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return
executed 50 times by 1 test: return &holder.value;
Executed by:
  • tst_QFileSelector
&holder.value;
executed 50 times by 1 test: return &holder.value;
Executed by:
  • tst_QFileSelector
} } } static QGlobalStatic<QFileSelectorSharedData, Q_QGS_sharedData::innerFunction, Q_QGS_sharedData::guard> sharedData;;
0-50
11static QBasicMutex sharedDataMutex;-
12-
13QFileSelectorPrivate::QFileSelectorPrivate()-
14 : QObjectPrivate()-
15{-
16}
executed 19 times by 1 test: end of block
Executed by:
  • tst_QFileSelector
19
17QFileSelector::QFileSelector(QObject *parent)-
18 : QObject(*(new QFileSelectorPrivate()), parent)-
19{-
20}
executed 19 times by 1 test: end of block
Executed by:
  • tst_QFileSelector
19
21-
22-
23-
24-
25QFileSelector::~QFileSelector()-
26{-
27}-
28QString QFileSelector::select(const QString &filePath) const-
29{-
30 const QFileSelectorPrivate * const d = d_func();-
31 return
executed 17 times by 1 test: return d->select(filePath);
Executed by:
  • tst_QFileSelector
d->select(filePath);
executed 17 times by 1 test: return d->select(filePath);
Executed by:
  • tst_QFileSelector
17
32}-
33-
34static bool isLocalScheme(const QString &file)-
35{-
36 bool local = file == QLatin1String("qrc");-
37-
38-
39-
40 return
executed 10 times by 1 test: return local;
Executed by:
  • tst_QFileSelector
local;
executed 10 times by 1 test: return local;
Executed by:
  • tst_QFileSelector
10
41}-
42QUrl QFileSelector::select(const QUrl &filePath) const-
43{-
44 const QFileSelectorPrivate * const d = d_func();-
45 if (!isLocalScheme(filePath.scheme())
!isLocalScheme...Path.scheme())Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
&& !filePath.isLocalFile()
!filePath.isLocalFile()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
2-4
46 return
executed 2 times by 1 test: return filePath;
Executed by:
  • tst_QFileSelector
filePath;
executed 2 times by 1 test: return filePath;
Executed by:
  • tst_QFileSelector
2
47 QUrl ret(filePath);-
48 if (isLocalScheme(filePath.scheme())
isLocalScheme(...Path.scheme())Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
) {
2
49 QLatin1String scheme(":");-
50-
51-
52-
53-
54-
55-
56 QString equivalentPath = scheme + filePath.path();-
57 QString selectedPath = d->select(equivalentPath);-
58 ret.setPath(selectedPath.remove(0, scheme.size()));-
59 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QFileSelector
else {
2
60 ret = QUrl::fromLocalFile(d->select(ret.toLocalFile()));-
61 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QFileSelector
2
62 return
executed 4 times by 1 test: return ret;
Executed by:
  • tst_QFileSelector
ret;
executed 4 times by 1 test: return ret;
Executed by:
  • tst_QFileSelector
4
63}-
64-
65static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)-
66{-
67-
68-
69-
70-
71 ((!(path.isEmpty() || path.endsWith(QLatin1Char('/')))) ? qt_assert("path.isEmpty() || path.endsWith(QLatin1Char('/'))",__FILE__,276) : qt_noop());-
72-
73 for (const QString &s : selectors) {-
74 QString prospectiveBase = path + QLatin1Char(selectorIndicator) + s + QLatin1Char('/');-
75 QStringList remainingSelectors = selectors;-
76 remainingSelectors.removeAll(s);-
77 if (!QDir(prospectiveBase).exists()
!QDir(prospect...Base).exists()Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 23 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
23-95
78 continue;
executed 95 times by 1 test: continue;
Executed by:
  • tst_QFileSelector
95
79 QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);-
80 if (!prospectiveFile.isEmpty()
!prospectiveFile.isEmpty()Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
4-19
81 return
executed 19 times by 1 test: return prospectiveFile;
Executed by:
  • tst_QFileSelector
prospectiveFile;
executed 19 times by 1 test: return prospectiveFile;
Executed by:
  • tst_QFileSelector
19
82 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFileSelector
4
83-
84-
85-
86 if (!QFile::exists(path + fileName)
!QFile::exists...th + fileName)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
4-20
87 return
executed 4 times by 1 test: return QString();
Executed by:
  • tst_QFileSelector
QString();
executed 4 times by 1 test: return QString();
Executed by:
  • tst_QFileSelector
4
88 return
executed 20 times by 1 test: return path + fileName;
Executed by:
  • tst_QFileSelector
path + fileName;
executed 20 times by 1 test: return path + fileName;
Executed by:
  • tst_QFileSelector
20
89}-
90-
91QString QFileSelectorPrivate::select(const QString &filePath) const-
92{-
93 const QFileSelector * const q = q_func();-
94 QFileInfo fi(filePath);-
95-
96 if (!fi.exists()
!fi.exists()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
1-20
97 return
executed 1 time by 1 test: return filePath;
Executed by:
  • tst_QFileSelector
filePath;
executed 1 time by 1 test: return filePath;
Executed by:
  • tst_QFileSelector
1
98-
99 QString ret = selectionHelper(fi.path().isEmpty() ? QString() : fi.path() + QLatin1Char('/'),-
100 fi.fileName(), q->allSelectors());-
101-
102 if (!ret.isEmpty()
!ret.isEmpty()Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEnever evaluated
)
0-20
103 return
executed 20 times by 1 test: return ret;
Executed by:
  • tst_QFileSelector
ret;
executed 20 times by 1 test: return ret;
Executed by:
  • tst_QFileSelector
20
104 return
never executed: return filePath;
filePath;
never executed: return filePath;
0
105}-
106-
107-
108-
109-
110QStringList QFileSelector::extraSelectors() const-
111{-
112 const QFileSelectorPrivate * const d = d_func();-
113 return
never executed: return d->extras;
d->extras;
never executed: return d->extras;
0
114}-
115-
116-
117-
118-
119-
120-
121void QFileSelector::setExtraSelectors(const QStringList &list)-
122{-
123 QFileSelectorPrivate * const d = d_func();-
124 d->extras = list;-
125}
executed 18 times by 1 test: end of block
Executed by:
  • tst_QFileSelector
18
126-
127-
128-
129-
130QStringList QFileSelector::allSelectors() const-
131{-
132 const QFileSelectorPrivate * const d = d_func();-
133 QMutexLocker locker(&sharedDataMutex);-
134 QFileSelectorPrivate::updateSelectors();-
135 return
executed 20 times by 1 test: return d->extras + sharedData->staticSelectors;
Executed by:
  • tst_QFileSelector
d->extras + sharedData->staticSelectors;
executed 20 times by 1 test: return d->extras + sharedData->staticSelectors;
Executed by:
  • tst_QFileSelector
20
136}-
137-
138void QFileSelectorPrivate::updateSelectors()-
139{-
140 if (!sharedData->staticSelectors.isEmpty()
!sharedData->s...tors.isEmpty()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
2-18
141 return;
executed 18 times by 1 test: return;
Executed by:
  • tst_QFileSelector
18
142-
143 QLatin1Char pathSep(',');-
144 QStringList envSelectors = QString::fromLatin1(qgetenv("QT_FILE_SELECTORS"))-
145 .split(pathSep, QString::SkipEmptyParts);-
146 if (envSelectors.count()
envSelectors.count()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
0-2
147 sharedData->staticSelectors << envSelectors;
never executed: sharedData->staticSelectors << envSelectors;
0
148-
149 if (!qEnvironmentVariableIsEmpty(env_override)
!qEnvironmentV...(env_override)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSelector
)
0-2
150 return;
never executed: return;
0
151-
152 sharedData->staticSelectors << sharedData->preloadedStatics;-
153-
154-
155 sharedData->staticSelectors << QLocale().name();-
156-
157 sharedData->staticSelectors << platformSelectors();-
158}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QFileSelector
2
159-
160QStringList QFileSelectorPrivate::platformSelectors()-
161{-
162-
163 QStringList ret;-
164 ret << ([]() -> QString { enum { Size = sizeof(u"" "unix")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "unix" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 3 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QFileSelector
qstring_literal_temp;
executed 3 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QFileSelector
}());
3
165-
166-
167 ret << QSysInfo::kernelType();-
168-
169-
170-
171-
172 QString productName = QSysInfo::productType();-
173-
174-
175-
176-
177 if (productName != QLatin1String("unknown")
productName !=...ing("unknown")Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QFileSelector
FALSEnever evaluated
)
0-3
178 ret << productName;
executed 3 times by 1 test: ret << productName;
Executed by:
  • tst_QFileSelector
3
179-
180 return
executed 3 times by 1 test: return ret;
Executed by:
  • tst_QFileSelector
ret;
executed 3 times by 1 test: return ret;
Executed by:
  • tst_QFileSelector
3
181}-
182-
183void QFileSelectorPrivate::addStatics(const QStringList &statics)-
184{-
185 QMutexLocker locker(&sharedDataMutex);-
186 sharedData->preloadedStatics << statics;-
187 sharedData->staticSelectors.clear();-
188}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QFileSelector
1
189-
190-
191-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9