Changeset 561 for trunk/tools/qvfb/qlock.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/qvfb/qlock.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 42 42 #include "qlock_p.h" 43 43 44 #ifndef QT_NO_QWS_MULTIPROCESS 44 45 #ifdef QT_NO_QWS_MULTIPROCESS 46 47 QT_BEGIN_NAMESPACE 48 49 /* no multiprocess - use a dummy */ 50 51 QLock::QLock(const QString & /*filename*/, char /*id*/, bool /*create*/) 52 : type(Read), data(0) 53 { 54 } 55 56 QLock::~QLock() 57 { 58 } 59 60 bool QLock::isValid() const 61 { 62 return true; 63 } 64 65 void QLock::lock(Type t) 66 { 67 data = (QLockData *)-1; 68 type = t; 69 } 70 71 void QLock::unlock() 72 { 73 data = 0; 74 } 75 76 bool QLock::locked() const 77 { 78 return data; 79 } 80 81 QT_END_NAMESPACE 82 83 #else // QT_NO_QWS_MULTIPROCESS 45 84 46 85 #include "qwssignalhandler_p.h" 86 47 87 #include <unistd.h> 48 88 #include <sys/types.h> … … 72 112 #include <signal.h> 73 113 74 #endif // QT_NO_QWS_MULTIPROCESS 114 #include <private/qcore_unix_p.h> // overrides QT_OPEN 115 116 117 QT_BEGIN_NAMESPACE 75 118 76 119 #define MAX_LOCKS 200 // maximum simultaneous read locks 77 120 78 QT_BEGIN_NAMESPACE79 80 81 #ifndef QT_NO_QWS_MULTIPROCESS82 121 class QLockData 83 122 { … … 90 129 bool owned; 91 130 }; 92 #endif // QT_NO_QWS_MULTIPROCESS93 131 94 132 /*! … … 97 135 98 136 \ingroup qws 99 \ingroup io100 137 101 138 \internal … … 125 162 QLock::QLock(const QString &filename, char id, bool create) 126 163 { 127 #ifdef QT_NO_QWS_MULTIPROCESS128 Q_UNUSED(filename);129 Q_UNUSED(id);130 Q_UNUSED(create);131 #else132 164 data = new QLockData; 133 165 data->count = 0; … … 135 167 data->file = QString(filename+id).toLocal8Bit().constData(); 136 168 for(int x = 0; x < 2; x++) { 137 data->id = open(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU);169 data->id = QT_OPEN(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU); 138 170 if(data->id != -1 || !create) { 139 171 data->owned = x; … … 162 194 qDebug() << "Error" << eno << strerror(eno); 163 195 } 164 #endif165 196 } 166 197 … … 173 204 QLock::~QLock() 174 205 { 175 #ifndef QT_NO_QWS_MULTIPROCESS176 206 if (locked()) 177 207 unlock(); 178 208 #ifdef Q_NO_SEMAPHORE 179 209 if(isValid()) { 180 close(data->id);210 QT_CLOSE(data->id); 181 211 if(data->owned) 182 212 unlink(data->file); … … 187 217 #endif 188 218 delete data; 189 #endif190 219 } 191 220 … … 199 228 bool QLock::isValid() const 200 229 { 201 #ifndef QT_NO_QWS_MULTIPROCESS202 230 return (data->id != -1); 203 #else204 return true;205 #endif206 231 } 207 232 … … 220 245 void QLock::lock(Type t) 221 246 { 222 #ifdef QT_NO_QWS_MULTIPROCESS223 Q_UNUSED(t);224 #else225 247 if (!data->count) { 226 248 #ifdef Q_NO_SEMAPHORE … … 255 277 } 256 278 data->count++; 257 #endif258 279 } 259 280 … … 268 289 void QLock::unlock() 269 290 { 270 #ifndef QT_NO_QWS_MULTIPROCESS271 291 if(data->count) { 272 292 data->count--; … … 297 317 qDebug("Unlock without corresponding lock"); 298 318 } 299 #endif300 319 } 301 320 … … 309 328 bool QLock::locked() const 310 329 { 311 #ifndef QT_NO_QWS_MULTIPROCESS312 330 return (data->count > 0); 313 #else314 return false;315 #endif316 331 } 317 332 318 333 QT_END_NAMESPACE 334 335 #endif // QT_NO_QWS_MULTIPROCESS 336
Note:
See TracChangeset
for help on using the changeset viewer.