util/qdesktopservices.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8class QOpenUrlHandlerRegistry : public QObject -
9{ -
10 public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; -
11public: -
12 inline QOpenUrlHandlerRegistry() : mutex(QMutex::Recursive) {}
executed: }
Execution Count:1
1
13 -
14 QMutex mutex; -
15 -
16 struct Handler -
17 { -
18 QObject *receiver; -
19 QByteArray name; -
20 }; -
21 typedef QHash<QString, Handler> HandlerHash; -
22 HandlerHash handlers; -
23 -
24public : -
25 void handlerDestroyed(QObject *handler); -
26 -
27}; -
28 -
29static QOpenUrlHandlerRegistry *handlerRegistry() { static QGlobalStatic<QOpenUrlHandlerRegistry > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QOpenUrlHandlerRegistry *x = new QOpenUrlHandlerRegistry; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QOpenUrlHandlerRegistry > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:5
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-5
30 -
31void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler) -
32{ -
33 HandlerHash::Iterator it = handlers.begin(); -
34 while (it != handlers.end()) {
evaluated: it != handlers.end()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
35 if (it->receiver == handler) {
evaluated: it->receiver == handler
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
36 it = handlers.erase(it); -
37 } else {
executed: }
Execution Count:2
2
38 ++it; -
39 }
executed: }
Execution Count:1
1
40 } -
41}
executed: }
Execution Count:2
2
42bool QDesktopServices::openUrl(const QUrl &url) -
43{ -
44 QOpenUrlHandlerRegistry *registry = handlerRegistry(); -
45 QMutexLocker locker(&registry->mutex); -
46 static bool insideOpenUrlHandler = false; -
47 -
48 if (!insideOpenUrlHandler) {
partially evaluated: !insideOpenUrlHandler
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
49 QOpenUrlHandlerRegistry::HandlerHash::ConstIterator handler = registry->handlers.constFind(url.scheme()); -
50 if (handler != registry->handlers.constEnd()) {
evaluated: handler != registry->handlers.constEnd()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
51 insideOpenUrlHandler = true; -
52 bool result = QMetaObject::invokeMethod(handler->receiver, handler->name.constData(), Qt::DirectConnection, QArgument<QUrl >("QUrl", url)); -
53 insideOpenUrlHandler = false; -
54 return result;
executed: return result;
Execution Count:2
2
55 } -
56 }
executed: }
Execution Count:1
1
57 if (!url.isValid())
partially evaluated: !url.isValid()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
58 return false;
executed: return false;
Execution Count:1
1
59 QPlatformServices *platformServices = QGuiApplicationPrivate::platformIntegration()->services(); -
60 if (!platformServices) {
never evaluated: !platformServices
0
61 QMessageLogger("util/qdesktopservices.cpp", 198, __PRETTY_FUNCTION__).warning("%s: The platform plugin does not support services.", __PRETTY_FUNCTION__); -
62 return false;
never executed: return false;
0
63 } -
64 return url.scheme() == QString::fromUtf8("" "file" "", sizeof("file") - 1) ? 0
65 platformServices->openDocument(url) : platformServices->openUrl(url);
never executed: return url.scheme() == QString::fromUtf8("" "file" "", sizeof("file") - 1) ? platformServices->openDocument(url) : platformServices->openUrl(url);
0
66} -
67void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, const char *method) -
68{ -
69 QOpenUrlHandlerRegistry *registry = handlerRegistry(); -
70 QMutexLocker locker(&registry->mutex); -
71 if (!receiver) {
partially evaluated: !receiver
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
72 registry->handlers.remove(scheme); -
73 return;
never executed: return;
0
74 } -
75 QOpenUrlHandlerRegistry::Handler h; -
76 h.receiver = receiver; -
77 h.name = method; -
78 registry->handlers.insert(scheme, h); -
79 QObject::connect(receiver, "2""destroyed(QObject*)", -
80 registry, "1""handlerDestroyed(QObject*)"); -
81}
executed: }
Execution Count:2
2
82 -
83 -
84 -
85 -
86 -
87 -
88void QDesktopServices::unsetUrlHandler(const QString &scheme) -
89{ -
90 setUrlHandler(scheme, 0, 0); -
91}
never executed: }
0
92extern __attribute__((visibility("default"))) QString qt_applicationName_noFallback(); -
93 -
94QString QDesktopServices::storageLocationImpl(QStandardPaths::StandardLocation type) -
95{ -
96 if (type == QStandardPaths::DataLocation) {
partially evaluated: type == QStandardPaths::DataLocation
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
97 -
98 -
99 -
100 const QString compatAppName = qt_applicationName_noFallback(); -
101 const QString baseDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); -
102 return baseDir + QLatin1String("/data/") 2
103 + QCoreApplication::organizationName() + QLatin1Char('/') 2
104 + compatAppName;
executed: return baseDir + QLatin1String("/data/") + QCoreApplication::organizationName() + QLatin1Char('/') + compatAppName;
Execution Count:2
2
105 -
106 } -
107 return QStandardPaths::writableLocation(type);
never executed: return QStandardPaths::writableLocation(type);
0
108} -
109 -
110 -
111 -
112 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial