Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qlockfile.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2013 David Faure <faure+bluesystems@kde.org> | - | ||||||||||||||||||
4 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
5 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
6 | ** | - | ||||||||||||||||||
7 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||
8 | ** | - | ||||||||||||||||||
9 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
10 | ** Commercial License Usage | - | ||||||||||||||||||
11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
15 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
16 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
17 | ** | - | ||||||||||||||||||
18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
20 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
21 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
22 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
23 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
24 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
25 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
26 | ** | - | ||||||||||||||||||
27 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
28 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
29 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
30 | ** | - | ||||||||||||||||||
31 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
32 | ** | - | ||||||||||||||||||
33 | ****************************************************************************/ | - | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | #include "qlockfile.h" | - | ||||||||||||||||||
36 | #include "qlockfile_p.h" | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | #include <QtCore/qthread.h> | - | ||||||||||||||||||
39 | #include <QtCore/qelapsedtimer.h> | - | ||||||||||||||||||
40 | #include <QtCore/qdatetime.h> | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | /*! | - | ||||||||||||||||||
45 | \class QLockFile | - | ||||||||||||||||||
46 | \inmodule QtCore | - | ||||||||||||||||||
47 | \brief The QLockFile class provides locking between processes using a file. | - | ||||||||||||||||||
48 | \since 5.1 | - | ||||||||||||||||||
49 | - | |||||||||||||||||||
50 | A lock file can be used to prevent multiple processes from accessing concurrently | - | ||||||||||||||||||
51 | the same resource. For instance, a configuration file on disk, or a socket, a port, | - | ||||||||||||||||||
52 | a region of shared memory... | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | Serialization is only guaranteed if all processes that access the shared resource | - | ||||||||||||||||||
55 | use QLockFile, with the same file path. | - | ||||||||||||||||||
56 | - | |||||||||||||||||||
57 | QLockFile supports two use cases: | - | ||||||||||||||||||
58 | to protect a resource for a short-term operation (e.g. verifying if a configuration | - | ||||||||||||||||||
59 | file has changed before saving new settings), and for long-lived protection of a | - | ||||||||||||||||||
60 | resource (e.g. a document opened by a user in an editor) for an indefinite amount of time. | - | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | When protecting for a short-term operation, it is acceptable to call lock() and wait | - | ||||||||||||||||||
63 | until any running operation finishes. | - | ||||||||||||||||||
64 | When protecting a resource over a long time, however, the application should always | - | ||||||||||||||||||
65 | call setStaleLockTime(0) and then tryLock() with a short timeout, in order to | - | ||||||||||||||||||
66 | warn the user that the resource is locked. | - | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | If the process holding the lock crashes, the lock file stays on disk and can prevent | - | ||||||||||||||||||
69 | any other process from accessing the shared resource, ever. For this reason, QLockFile | - | ||||||||||||||||||
70 | tries to detect such a "stale" lock file, based on the process ID written into the file. | - | ||||||||||||||||||
71 | To cover the situation that the process ID got reused meanwhile, the current process name is | - | ||||||||||||||||||
72 | compared to the name of the process that corresponds to the process ID from the lock file. | - | ||||||||||||||||||
73 | If the process names differ, the lock file is considered stale. | - | ||||||||||||||||||
74 | Additionally, the last modification time of the lock file (30s by default, for the use case of a | - | ||||||||||||||||||
75 | short-lived operation) is taken into account. | - | ||||||||||||||||||
76 | If the lock file is found to be stale, it will be deleted. | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | For the use case of protecting a resource over a long time, you should therefore call | - | ||||||||||||||||||
79 | setStaleLockTime(0), and when tryLock() returns LockFailedError, inform the user | - | ||||||||||||||||||
80 | that the document is locked, possibly using getLockInfo() for more details. | - | ||||||||||||||||||
81 | */ | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | /*! | - | ||||||||||||||||||
84 | \enum QLockFile::LockError | - | ||||||||||||||||||
85 | - | |||||||||||||||||||
86 | This enum describes the result of the last call to lock() or tryLock(). | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | \value NoError The lock was acquired successfully. | - | ||||||||||||||||||
89 | \value LockFailedError The lock could not be acquired because another process holds it. | - | ||||||||||||||||||
90 | \value PermissionError The lock file could not be created, for lack of permissions | - | ||||||||||||||||||
91 | in the parent directory. | - | ||||||||||||||||||
92 | \value UnknownError Another error happened, for instance a full partition | - | ||||||||||||||||||
93 | prevented writing out the lock file. | - | ||||||||||||||||||
94 | */ | - | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | /*! | - | ||||||||||||||||||
97 | Constructs a new lock file object. | - | ||||||||||||||||||
98 | The object is created in an unlocked state. | - | ||||||||||||||||||
99 | When calling lock() or tryLock(), a lock file named \a fileName will be created, | - | ||||||||||||||||||
100 | if it doesn't already exist. | - | ||||||||||||||||||
101 | - | |||||||||||||||||||
102 | \sa lock(), unlock() | - | ||||||||||||||||||
103 | */ | - | ||||||||||||||||||
104 | QLockFile::QLockFile(const QString &fileName) | - | ||||||||||||||||||
105 | : d_ptr(new QLockFilePrivate(fileName)) | - | ||||||||||||||||||
106 | { | - | ||||||||||||||||||
107 | } executed 4198 times by 32 tests: end of block Executed by:
| 4198 | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | /*! | - | ||||||||||||||||||
110 | Destroys the lock file object. | - | ||||||||||||||||||
111 | If the lock was acquired, this will release the lock, by deleting the lock file. | - | ||||||||||||||||||
112 | */ | - | ||||||||||||||||||
113 | QLockFile::~QLockFile() | - | ||||||||||||||||||
114 | { | - | ||||||||||||||||||
115 | unlock(); | - | ||||||||||||||||||
116 | } executed 4198 times by 32 tests: end of block Executed by:
| 4198 | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | /*! | - | ||||||||||||||||||
119 | Sets \a staleLockTime to be the time in milliseconds after which | - | ||||||||||||||||||
120 | a lock file is considered stale. | - | ||||||||||||||||||
121 | The default value is 30000, i.e. 30 seconds. | - | ||||||||||||||||||
122 | If your application typically keeps the file locked for more than 30 seconds | - | ||||||||||||||||||
123 | (for instance while saving megabytes of data for 2 minutes), you should set | - | ||||||||||||||||||
124 | a bigger value using setStaleLockTime(). | - | ||||||||||||||||||
125 | - | |||||||||||||||||||
126 | The value of \a staleLockTime is used by lock() and tryLock() in order | - | ||||||||||||||||||
127 | to determine when an existing lock file is considered stale, i.e. left over | - | ||||||||||||||||||
128 | by a crashed process. This is useful for the case where the PID got reused | - | ||||||||||||||||||
129 | meanwhile, so one way to detect a stale lock file is by the fact that | - | ||||||||||||||||||
130 | it has been around for a long time. | - | ||||||||||||||||||
131 | - | |||||||||||||||||||
132 | \sa staleLockTime() | - | ||||||||||||||||||
133 | */ | - | ||||||||||||||||||
134 | void QLockFile::setStaleLockTime(int staleLockTime) | - | ||||||||||||||||||
135 | { | - | ||||||||||||||||||
136 | Q_D(QLockFile); | - | ||||||||||||||||||
137 | d->staleLockTime = staleLockTime; | - | ||||||||||||||||||
138 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
139 | - | |||||||||||||||||||
140 | /*! | - | ||||||||||||||||||
141 | Returns the time in milliseconds after which | - | ||||||||||||||||||
142 | a lock file is considered stale. | - | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | \sa setStaleLockTime() | - | ||||||||||||||||||
145 | */ | - | ||||||||||||||||||
146 | int QLockFile::staleLockTime() const | - | ||||||||||||||||||
147 | { | - | ||||||||||||||||||
148 | Q_D(const QLockFile); | - | ||||||||||||||||||
149 | return d->staleLockTime; never executed: return d->staleLockTime; | 0 | ||||||||||||||||||
150 | } | - | ||||||||||||||||||
151 | - | |||||||||||||||||||
152 | /*! | - | ||||||||||||||||||
153 | Returns \c true if the lock was acquired by this QLockFile instance, | - | ||||||||||||||||||
154 | otherwise returns \c false. | - | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | \sa lock(), unlock(), tryLock() | - | ||||||||||||||||||
157 | */ | - | ||||||||||||||||||
158 | bool QLockFile::isLocked() const | - | ||||||||||||||||||
159 | { | - | ||||||||||||||||||
160 | Q_D(const QLockFile); | - | ||||||||||||||||||
161 | return d->isLocked; executed 3 times by 2 tests: return d->isLocked; Executed by:
| 3 | ||||||||||||||||||
162 | } | - | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | /*! | - | ||||||||||||||||||
165 | Creates the lock file. | - | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | If another process (or another thread) has created the lock file already, | - | ||||||||||||||||||
168 | this function will block until that process (or thread) releases it. | - | ||||||||||||||||||
169 | - | |||||||||||||||||||
170 | Calling this function multiple times on the same lock from the same | - | ||||||||||||||||||
171 | thread without unlocking first is not allowed. This function will | - | ||||||||||||||||||
172 | \e dead-lock when the file is locked recursively. | - | ||||||||||||||||||
173 | - | |||||||||||||||||||
174 | Returns \c true if the lock was acquired, false if it could not be acquired | - | ||||||||||||||||||
175 | due to an unrecoverable error, such as no permissions in the parent directory. | - | ||||||||||||||||||
176 | - | |||||||||||||||||||
177 | \sa unlock(), tryLock() | - | ||||||||||||||||||
178 | */ | - | ||||||||||||||||||
179 | bool QLockFile::lock() | - | ||||||||||||||||||
180 | { | - | ||||||||||||||||||
181 | return tryLock(-1); executed 574 times by 8 tests: return tryLock(-1); Executed by:
| 574 | ||||||||||||||||||
182 | } | - | ||||||||||||||||||
183 | - | |||||||||||||||||||
184 | /*! | - | ||||||||||||||||||
185 | Attempts to create the lock file. This function returns \c true if the | - | ||||||||||||||||||
186 | lock was obtained; otherwise it returns \c false. If another process (or | - | ||||||||||||||||||
187 | another thread) has created the lock file already, this function will | - | ||||||||||||||||||
188 | wait for at most \a timeout milliseconds for the lock file to become | - | ||||||||||||||||||
189 | available. | - | ||||||||||||||||||
190 | - | |||||||||||||||||||
191 | Note: Passing a negative number as the \a timeout is equivalent to | - | ||||||||||||||||||
192 | calling lock(), i.e. this function will wait forever until the lock | - | ||||||||||||||||||
193 | file can be locked if \a timeout is negative. | - | ||||||||||||||||||
194 | - | |||||||||||||||||||
195 | If the lock was obtained, it must be released with unlock() | - | ||||||||||||||||||
196 | before another process (or thread) can successfully lock it. | - | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | Calling this function multiple times on the same lock from the same | - | ||||||||||||||||||
199 | thread without unlocking first is not allowed, this function will | - | ||||||||||||||||||
200 | \e always return false when attempting to lock the file recursively. | - | ||||||||||||||||||
201 | - | |||||||||||||||||||
202 | \sa lock(), unlock() | - | ||||||||||||||||||
203 | */ | - | ||||||||||||||||||
204 | bool QLockFile::tryLock(int timeout) | - | ||||||||||||||||||
205 | { | - | ||||||||||||||||||
206 | Q_D(QLockFile); | - | ||||||||||||||||||
207 | QElapsedTimer timer; | - | ||||||||||||||||||
208 | if (timeout > 0)
| 4-580 | ||||||||||||||||||
209 | timer.start(); executed 4 times by 1 test: timer.start(); Executed by:
| 4 | ||||||||||||||||||
210 | int sleepTime = 100; | - | ||||||||||||||||||
211 | forever { | - | ||||||||||||||||||
212 | d->lockError = d->tryLock_sys(); | - | ||||||||||||||||||
213 | switch (d->lockError) { | - | ||||||||||||||||||
214 | case NoError: executed 578 times by 8 tests: case NoError: Executed by:
| 578 | ||||||||||||||||||
215 | d->isLocked = true; | - | ||||||||||||||||||
216 | return true; executed 578 times by 8 tests: return true; Executed by:
| 578 | ||||||||||||||||||
217 | case PermissionError: executed 1 time by 1 test: case PermissionError: Executed by:
| 1 | ||||||||||||||||||
218 | case UnknownError: never executed: case UnknownError: | 0 | ||||||||||||||||||
219 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||
220 | case LockFailedError: executed 17 times by 1 test: case LockFailedError: Executed by:
| 17 | ||||||||||||||||||
221 | if (!d->isLocked && d->isApparentlyStale()) {
| 1-13 | ||||||||||||||||||
222 | // Stale lock from another thread/process | - | ||||||||||||||||||
223 | // Ensure two processes don't remove it at the same time | - | ||||||||||||||||||
224 | QLockFile rmlock(d->fileName + QStringLiteral(".rmlock")); executed 1 time by 1 test: return qstring_literal_temp; Executed by:
| 1 | ||||||||||||||||||
225 | if (rmlock.tryLock()) {
| 0-1 | ||||||||||||||||||
226 | if (d->isApparentlyStale() && d->removeStaleLock())
| 0-1 | ||||||||||||||||||
227 | continue; executed 1 time by 1 test: continue; Executed by:
| 1 | ||||||||||||||||||
228 | } never executed: end of block | 0 | ||||||||||||||||||
229 | } never executed: end of block | 0 | ||||||||||||||||||
230 | break; executed 16 times by 1 test: break; Executed by:
| 16 | ||||||||||||||||||
231 | } | - | ||||||||||||||||||
232 | if (timeout == 0 || (timeout > 0 && timer.hasExpired(timeout)))
| 2-13 | ||||||||||||||||||
233 | return false; executed 5 times by 1 test: return false; Executed by:
| 5 | ||||||||||||||||||
234 | QThread::msleep(sleepTime); | - | ||||||||||||||||||
235 | if (sleepTime < 5 * 1000)
| 0-11 | ||||||||||||||||||
236 | sleepTime *= 2; executed 11 times by 1 test: sleepTime *= 2; Executed by:
| 11 | ||||||||||||||||||
237 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||
238 | // not reached | - | ||||||||||||||||||
239 | return false; never executed: return false; | 0 | ||||||||||||||||||
240 | } | - | ||||||||||||||||||
241 | - | |||||||||||||||||||
242 | /*! | - | ||||||||||||||||||
243 | \fn void QLockFile::unlock() | - | ||||||||||||||||||
244 | Releases the lock, by deleting the lock file. | - | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | Calling unlock() without locking the file first, does nothing. | - | ||||||||||||||||||
247 | - | |||||||||||||||||||
248 | \sa lock(), tryLock() | - | ||||||||||||||||||
249 | */ | - | ||||||||||||||||||
250 | - | |||||||||||||||||||
251 | /*! | - | ||||||||||||||||||
252 | Retrieves information about the current owner of the lock file. | - | ||||||||||||||||||
253 | - | |||||||||||||||||||
254 | If tryLock() returns \c false, and error() returns LockFailedError, | - | ||||||||||||||||||
255 | this function can be called to find out more information about the existing | - | ||||||||||||||||||
256 | lock file: | - | ||||||||||||||||||
257 | \list | - | ||||||||||||||||||
258 | \li the PID of the application (returned in \a pid) | - | ||||||||||||||||||
259 | \li the \a hostname it's running on (useful in case of networked filesystems), | - | ||||||||||||||||||
260 | \li the name of the application which created it (returned in \a appname), | - | ||||||||||||||||||
261 | \endlist | - | ||||||||||||||||||
262 | - | |||||||||||||||||||
263 | Note that tryLock() automatically deleted the file if there is no | - | ||||||||||||||||||
264 | running application with this PID, so LockFailedError can only happen if there is | - | ||||||||||||||||||
265 | an application with this PID (it could be unrelated though). | - | ||||||||||||||||||
266 | - | |||||||||||||||||||
267 | This can be used to inform users about the existing lock file and give them | - | ||||||||||||||||||
268 | the choice to delete it. After removing the file using removeStaleLockFile(), | - | ||||||||||||||||||
269 | the application can call tryLock() again. | - | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | This function returns \c true if the information could be successfully retrieved, false | - | ||||||||||||||||||
272 | if the lock file doesn't exist or doesn't contain the expected data. | - | ||||||||||||||||||
273 | This can happen if the lock file was deleted between the time where tryLock() failed | - | ||||||||||||||||||
274 | and the call to this function. Simply call tryLock() again if this happens. | - | ||||||||||||||||||
275 | */ | - | ||||||||||||||||||
276 | bool QLockFile::getLockInfo(qint64 *pid, QString *hostname, QString *appname) const | - | ||||||||||||||||||
277 | { | - | ||||||||||||||||||
278 | Q_D(const QLockFile); | - | ||||||||||||||||||
279 | return d->getLockInfo(pid, hostname, appname); executed 1 time by 1 test: return d->getLockInfo(pid, hostname, appname); Executed by:
| 1 | ||||||||||||||||||
280 | } | - | ||||||||||||||||||
281 | - | |||||||||||||||||||
282 | bool QLockFilePrivate::getLockInfo(qint64 *pid, QString *hostname, QString *appname) const | - | ||||||||||||||||||
283 | { | - | ||||||||||||||||||
284 | QFile reader(fileName); | - | ||||||||||||||||||
285 | if (!reader.open(QIODevice::ReadOnly))
| 0-15 | ||||||||||||||||||
286 | return false; never executed: return false; | 0 | ||||||||||||||||||
287 | - | |||||||||||||||||||
288 | QByteArray pidLine = reader.readLine(); | - | ||||||||||||||||||
289 | pidLine.chop(1); | - | ||||||||||||||||||
290 | QByteArray appNameLine = reader.readLine(); | - | ||||||||||||||||||
291 | appNameLine.chop(1); | - | ||||||||||||||||||
292 | QByteArray hostNameLine = reader.readLine(); | - | ||||||||||||||||||
293 | hostNameLine.chop(1); | - | ||||||||||||||||||
294 | if (pidLine.isEmpty())
| 2-13 | ||||||||||||||||||
295 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||
296 | - | |||||||||||||||||||
297 | qint64 thePid = pidLine.toLongLong(); | - | ||||||||||||||||||
298 | if (pid)
| 0-13 | ||||||||||||||||||
299 | *pid = thePid; executed 13 times by 1 test: *pid = thePid; Executed by:
| 13 | ||||||||||||||||||
300 | if (appname)
| 0-13 | ||||||||||||||||||
301 | *appname = QString::fromUtf8(appNameLine); executed 13 times by 1 test: *appname = QString::fromUtf8(appNameLine); Executed by:
| 13 | ||||||||||||||||||
302 | if (hostname)
| 0-13 | ||||||||||||||||||
303 | *hostname = QString::fromUtf8(hostNameLine); executed 13 times by 1 test: *hostname = QString::fromUtf8(hostNameLine); Executed by:
| 13 | ||||||||||||||||||
304 | return thePid > 0; executed 13 times by 1 test: return thePid > 0; Executed by:
| 13 | ||||||||||||||||||
305 | } | - | ||||||||||||||||||
306 | - | |||||||||||||||||||
307 | /*! | - | ||||||||||||||||||
308 | Attempts to forcefully remove an existing lock file. | - | ||||||||||||||||||
309 | - | |||||||||||||||||||
310 | Calling this is not recommended when protecting a short-lived operation: QLockFile | - | ||||||||||||||||||
311 | already takes care of removing lock files after they are older than staleLockTime(). | - | ||||||||||||||||||
312 | - | |||||||||||||||||||
313 | This method should only be called when protecting a resource for a long time, i.e. | - | ||||||||||||||||||
314 | with staleLockTime(0), and after tryLock() returned LockFailedError, and the user | - | ||||||||||||||||||
315 | agreed on removing the lock file. | - | ||||||||||||||||||
316 | - | |||||||||||||||||||
317 | Returns \c true on success, false if the lock file couldn't be removed. This happens | - | ||||||||||||||||||
318 | on Windows, when the application owning the lock is still running. | - | ||||||||||||||||||
319 | */ | - | ||||||||||||||||||
320 | bool QLockFile::removeStaleLockFile() | - | ||||||||||||||||||
321 | { | - | ||||||||||||||||||
322 | Q_D(QLockFile); | - | ||||||||||||||||||
323 | if (d->isLocked) {
| 0 | ||||||||||||||||||
324 | qWarning("removeStaleLockFile can only be called when not holding the lock"); | - | ||||||||||||||||||
325 | return false; never executed: return false; | 0 | ||||||||||||||||||
326 | } | - | ||||||||||||||||||
327 | return d->removeStaleLock(); never executed: return d->removeStaleLock(); | 0 | ||||||||||||||||||
328 | } | - | ||||||||||||||||||
329 | - | |||||||||||||||||||
330 | /*! | - | ||||||||||||||||||
331 | Returns the lock file error status. | - | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | If tryLock() returns \c false, this function can be called to find out | - | ||||||||||||||||||
334 | the reason why the locking failed. | - | ||||||||||||||||||
335 | */ | - | ||||||||||||||||||
336 | QLockFile::LockError QLockFile::error() const | - | ||||||||||||||||||
337 | { | - | ||||||||||||||||||
338 | Q_D(const QLockFile); | - | ||||||||||||||||||
339 | return d->lockError; executed 14 times by 1 test: return d->lockError; Executed by:
| 14 | ||||||||||||||||||
340 | } | - | ||||||||||||||||||
341 | - | |||||||||||||||||||
342 | QT_END_NAMESPACE | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |