]>
Commit | Line | Data |
---|---|---|
ae7fcb39 | 1 | --- qt-copy/tools/tools.pro.orig 2005-05-13 16:39:18.000000000 +0200 |
2 | +++ qt-copy/tools/tools.pro 2005-05-13 20:02:31.761482520 +0200 | |
72fb07e3 | 3 | @@ -7,7 +7,7 @@ |
ae7fcb39 | 4 | assistant \ |
72fb07e3 | 5 | porting \ |
a1b24f1e | 6 | qtestlib \ |
7 | - pixeltool | |
8 | + pixeltool qvfb | |
9 | contains(QT_EDITION, Console) { | |
10 | SUBDIRS += designer/src/uitools # Linguist depends on this | |
11 | } else { | |
2b5e8641 JB |
12 | diff -Nur qt-x11-opensource-src-4.1.4/src/gui/embedded.orig/qlock.cpp qt-x11-opensource-src-4.1.4/src/gui/embedded/qlock.cpp |
13 | --- qt-x11-opensource-src-4.1.4/src/gui/embedded.orig/qlock.cpp 1970-01-01 01:00:00.000000000 +0100 | |
14 | +++ qt-x11-opensource-src-4.1.4/src/gui/embedded/qlock.cpp 2006-07-02 11:35:54.386518000 +0200 | |
15 | @@ -0,0 +1,289 @@ | |
16 | +/**************************************************************************** | |
17 | +** | |
18 | +** Copyright (C) 1992-2006 Trolltech AS. All rights reserved. | |
19 | +** | |
20 | +** This file is part of the QtGui module of the Qt Toolkit. | |
21 | +** | |
22 | +** This file may be used under the terms of the GNU General Public | |
23 | +** License version 2.0 as published by the Free Software Foundation | |
24 | +** and appearing in the file LICENSE.GPL included in the packaging of | |
25 | +** this file. Please review the following information to ensure GNU | |
26 | +** General Public Licensing requirements will be met: | |
27 | +** http://www.trolltech.com/products/qt/opensource.html | |
28 | +** | |
29 | +** If you are unsure which license is appropriate for your use, please | |
30 | +** review the following information: | |
31 | +** http://www.trolltech.com/products/qt/licensing.html or contact the | |
32 | +** sales department at sales@trolltech.com. | |
33 | +** | |
34 | +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
35 | +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
36 | +** | |
37 | +****************************************************************************/ | |
38 | + | |
39 | +#include "qlock_p.h" | |
40 | + | |
41 | +#ifndef QT_NO_QWS_MULTIPROCESS | |
42 | + | |
43 | +#include <unistd.h> | |
44 | +#include <sys/types.h> | |
45 | +#if defined(Q_OS_DARWIN) | |
46 | +#define Q_NO_SEMAPHORE | |
47 | +#include <sys/stat.h> | |
48 | +#include <sys/file.h> | |
49 | +#else | |
50 | +#include <sys/sem.h> | |
51 | +#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) \ | |
52 | + || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_BSDI) | |
53 | +/* union semun is defined by including <sys/sem.h> */ | |
54 | +#else | |
55 | +/* according to X/OPEN we have to define it ourselves */ | |
56 | +union semun { | |
57 | + int val; /* value for SETVAL */ | |
58 | + struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ | |
59 | + unsigned short *array; /* array for GETALL, SETALL */ | |
60 | +}; | |
61 | +#endif | |
62 | +#endif | |
63 | +#include <sys/ipc.h> | |
64 | +#include <string.h> | |
65 | +#include <errno.h> | |
66 | +#include <qdebug.h> | |
67 | + | |
68 | +#define MAX_LOCKS 200 // maximum simultaneous read locks | |
69 | + | |
70 | +class QLockData | |
71 | +{ | |
72 | +public: | |
73 | +#ifdef Q_NO_SEMAPHORE | |
74 | + QByteArray file; | |
75 | +#endif | |
76 | + int id; | |
77 | + int count; | |
78 | + bool owned; | |
79 | +}; | |
80 | + | |
81 | +#endif | |
82 | + | |
83 | +/*! | |
84 | + \class QLock qlock_p.h | |
85 | + \brief The QLock class is a wrapper for a System V shared semaphore. | |
86 | + | |
87 | + \ingroup qws | |
88 | + \ingroup io | |
89 | + | |
90 | + \internal | |
91 | + | |
92 | + It is used by \l {Qtopia Core} for synchronizing access to the graphics | |
93 | + card and shared memory region between processes. | |
94 | +*/ | |
95 | + | |
96 | +/*! | |
97 | + \enum QLock::Type | |
98 | + | |
99 | + \value Read | |
100 | + \value Write | |
101 | +*/ | |
102 | + | |
103 | +/*! | |
104 | + \fn QLock::QLock(const QString &filename, char id, bool create) | |
105 | + | |
106 | + Creates a lock. \a filename is the file path of the Unix-domain | |
107 | + socket the \l {Qtopia Core} client is using. \a id is the name of the | |
108 | + particular lock to be created on that socket. If \a create is true | |
109 | + the lock is to be created (as the \l {Qtopia Core} server does); if \a | |
110 | + create is false the lock should exist already (as the \l {Qtopia Core} | |
111 | + client expects). | |
112 | +*/ | |
113 | + | |
114 | +QLock::QLock(const QString &filename, char id, bool create) | |
115 | +{ | |
116 | +#ifdef QT_NO_QWS_MULTIPROCESS | |
117 | + Q_UNUSED(filename); | |
118 | + Q_UNUSED(id); | |
119 | + Q_UNUSED(create); | |
120 | +#else | |
121 | + data = new QLockData; | |
122 | + data->count = 0; | |
123 | +#ifdef Q_NO_SEMAPHORE | |
124 | + data->file = QString(filename+id).toLocal8Bit().constData(); | |
125 | + for(int x = 0; x < 2; x++) { | |
126 | + data->id = open(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU); | |
127 | + if(data->id != -1 || !create) { | |
128 | + data->owned = x; | |
129 | + break; | |
130 | + } | |
131 | + } | |
132 | +#else | |
133 | + key_t semkey = ftok(filename.toLocal8Bit().constData(), id); | |
134 | + data->id = semget(semkey,0,0); | |
135 | + data->owned = create; | |
136 | + if (create) { | |
137 | + semun arg; arg.val = 0; | |
138 | + if (data->id != -1) | |
139 | + semctl(data->id,0,IPC_RMID,arg); | |
140 | + data->id = semget(semkey,1,IPC_CREAT|0600); | |
141 | + arg.val = MAX_LOCKS; | |
142 | + semctl(data->id,0,SETVAL,arg); | |
143 | + } | |
144 | +#endif | |
145 | + if (data->id == -1) { | |
146 | + qWarning("Cannot %s semaphore %s '%c'", (create ? "create" : "get"), | |
147 | + qPrintable(filename), id); | |
148 | + qDebug() << "Error" << errno << strerror(errno); | |
149 | + } | |
150 | +#endif | |
151 | +} | |
152 | + | |
153 | +/*! | |
154 | + \fn QLock::~QLock() | |
155 | + | |
156 | + Destroys a lock | |
157 | +*/ | |
158 | + | |
159 | +QLock::~QLock() | |
160 | +{ | |
161 | +#ifndef QT_NO_QWS_MULTIPROCESS | |
162 | + if (locked()) | |
163 | + unlock(); | |
164 | +#ifdef Q_NO_SEMAPHORE | |
165 | + if(isValid()) { | |
166 | + close(data->id); | |
167 | + if(data->owned) | |
168 | + unlink(data->file); | |
169 | + } | |
170 | +#else | |
171 | + if(data->owned) { | |
172 | + semun arg; arg.val = 0; | |
173 | + semctl(data->id, 0, IPC_RMID, arg); | |
174 | + } | |
175 | +#endif | |
176 | + delete data; | |
177 | +#endif | |
178 | +} | |
179 | + | |
180 | +/*! | |
181 | + \fn bool QLock::isValid() const | |
182 | + | |
183 | + Returns true if the lock constructor was successful; returns false if | |
184 | + the lock could not be created or was not available to connect to. | |
185 | +*/ | |
186 | + | |
187 | +bool QLock::isValid() const | |
188 | +{ | |
189 | +#ifndef QT_NO_QWS_MULTIPROCESS | |
190 | + return (data->id != -1); | |
191 | +#else | |
192 | + return true; | |
193 | +#endif | |
194 | +} | |
195 | + | |
196 | +/*! | |
197 | + Locks the semaphore with a lock of type \a t. Locks can either be | |
198 | + \c Read or \c Write. If a lock is \c Read, attempts by other | |
199 | + processes to obtain \c Read locks will succeed, and \c Write | |
200 | + attempts will block until the lock is unlocked. If locked as \c | |
201 | + Write, all attempts to lock by other processes will block until | |
202 | + the lock is unlocked. Locks are stacked: i.e. a given QLock can be | |
203 | + locked multiple times by the same process without blocking, and | |
204 | + will only be unlocked after a corresponding number of unlock() | |
205 | + calls. | |
206 | +*/ | |
207 | + | |
208 | +void QLock::lock(Type t) | |
209 | +{ | |
210 | +#ifdef QT_NO_QWS_MULTIPROCESS | |
211 | + Q_UNUSED(t); | |
212 | +#else | |
213 | + if (!data->count) { | |
214 | +#ifdef Q_NO_SEMAPHORE | |
215 | + int op = LOCK_SH; | |
216 | + if(t == Write) | |
217 | + op = LOCK_EX; | |
218 | + for(int rv=1; rv;) { | |
219 | + rv = flock(data->id, op); | |
220 | + if (rv == -1 && errno != EINTR) | |
221 | + qDebug("Semop lock failure %s",strerror(errno)); | |
222 | + } | |
223 | +#else | |
224 | + sembuf sops; | |
225 | + sops.sem_num = 0; | |
226 | + sops.sem_flg = SEM_UNDO; | |
227 | + | |
228 | + if (t == Write) { | |
229 | + sops.sem_op = -MAX_LOCKS; | |
230 | + type = Write; | |
231 | + } else { | |
232 | + sops.sem_op = -1; | |
233 | + type = Read; | |
234 | + } | |
235 | + | |
236 | + int rv; | |
237 | + do { | |
238 | + rv = semop(data->id,&sops,1); | |
239 | + if (rv == -1 && errno != EINTR) | |
240 | + qDebug("Semop lock failure %s",strerror(errno)); | |
241 | + } while (rv == -1 && errno == EINTR); | |
242 | +#endif | |
243 | + } | |
244 | + data->count++; | |
245 | +#endif | |
246 | +} | |
247 | + | |
248 | +/*! | |
249 | + \fn void QLock::unlock() | |
250 | + | |
251 | + Unlocks the semaphore. If other processes were blocking waiting to | |
252 | + lock() the semaphore, one of them will wake up and succeed in | |
253 | + lock()ing. | |
254 | +*/ | |
255 | + | |
256 | +void QLock::unlock() | |
257 | +{ | |
258 | +#ifndef QT_NO_QWS_MULTIPROCESS | |
259 | + if(data->count) { | |
260 | + data->count--; | |
261 | + if(!data->count) { | |
262 | +#ifdef Q_NO_SEMAPHORE | |
263 | + for(int rv=1; rv;) { | |
264 | + rv = flock(data->id, LOCK_UN); | |
265 | + if (rv == -1 && errno != EINTR) | |
266 | + qDebug("Semop lock failure %s",strerror(errno)); | |
267 | + } | |
268 | +#else | |
269 | + sembuf sops; | |
270 | + sops.sem_num = 0; | |
271 | + sops.sem_op = 1; | |
272 | + sops.sem_flg = SEM_UNDO; | |
273 | + if (type == Write) | |
274 | + sops.sem_op = MAX_LOCKS; | |
275 | + | |
276 | + int rv; | |
277 | + do { | |
278 | + rv = semop(data->id,&sops,1); | |
279 | + if (rv == -1 && errno != EINTR) | |
280 | + qDebug("Semop unlock failure %s",strerror(errno)); | |
281 | + } while (rv == -1 && errno == EINTR); | |
282 | +#endif | |
283 | + } | |
284 | + } else { | |
285 | + qDebug("Unlock without corresponding lock"); | |
286 | + } | |
287 | +#endif | |
288 | +} | |
289 | + | |
290 | +/*! | |
291 | + \fn bool QLock::locked() const | |
292 | + | |
293 | + Returns true if the lock is currently held by the current process; | |
294 | + otherwise returns false. | |
295 | +*/ | |
296 | + | |
297 | +bool QLock::locked() const | |
298 | +{ | |
299 | +#ifndef QT_NO_QWS_MULTIPROCESS | |
300 | + return (data->count > 0); | |
301 | +#else | |
302 | + return false; | |
303 | +#endif | |
304 | +} | |
305 | diff -Nur qt-x11-opensource-src-4.1.4/src/gui/embedded.orig/qlock_p.h qt-x11-opensource-src-4.1.4/src/gui/embedded/qlock_p.h | |
306 | --- qt-x11-opensource-src-4.1.4/src/gui/embedded.orig/qlock_p.h 1970-01-01 01:00:00.000000000 +0100 | |
307 | +++ qt-x11-opensource-src-4.1.4/src/gui/embedded/qlock_p.h 2006-07-02 11:36:23.952365750 +0200 | |
308 | @@ -0,0 +1,78 @@ | |
309 | +/**************************************************************************** | |
310 | +** | |
311 | +** Copyright (C) 1992-2006 Trolltech AS. All rights reserved. | |
312 | +** | |
313 | +** This file is part of the QtGui module of the Qt Toolkit. | |
314 | +** | |
315 | +** This file may be used under the terms of the GNU General Public | |
316 | +** License version 2.0 as published by the Free Software Foundation | |
317 | +** and appearing in the file LICENSE.GPL included in the packaging of | |
318 | +** this file. Please review the following information to ensure GNU | |
319 | +** General Public Licensing requirements will be met: | |
320 | +** http://www.trolltech.com/products/qt/opensource.html | |
321 | +** | |
322 | +** If you are unsure which license is appropriate for your use, please | |
323 | +** review the following information: | |
324 | +** http://www.trolltech.com/products/qt/licensing.html or contact the | |
325 | +** sales department at sales@trolltech.com. | |
326 | +** | |
327 | +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
328 | +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
329 | +** | |
330 | +****************************************************************************/ | |
331 | + | |
332 | +#ifndef QLOCK_P_H | |
333 | +#define QLOCK_P_H | |
334 | + | |
335 | +// | |
336 | +// W A R N I N G | |
337 | +// ------------- | |
338 | +// | |
339 | +// This file is not part of the Qt API. This header file may | |
340 | +// change from version to version without notice, or even be | |
341 | +// removed. | |
342 | +// | |
343 | +// We mean it. | |
344 | +// | |
345 | + | |
346 | +#include "QtCore/qstring.h" | |
347 | + | |
348 | +class QLockData; | |
349 | + | |
350 | +class Q_GUI_EXPORT QLock | |
351 | +{ | |
352 | +public: | |
353 | + QLock(const QString &filename, char id, bool create = false); | |
354 | + ~QLock(); | |
355 | + | |
356 | + enum Type { Read, Write }; | |
357 | + | |
358 | + bool isValid() const; | |
359 | + void lock(Type type); | |
360 | + void unlock(); | |
361 | + bool locked() const; | |
362 | + | |
363 | +private: | |
364 | + Type type; | |
365 | + QLockData *data; | |
366 | +}; | |
367 | + | |
368 | + | |
369 | +// Nice class for ensuring the lock is released. | |
370 | +// Just create one on the stack and the lock is automatically released | |
371 | +// when QLockHandle is destructed. | |
372 | +class Q_GUI_EXPORT QLockHandle | |
373 | +{ | |
374 | +public: | |
375 | + QLockHandle(QLock *l, QLock::Type type) : qlock(l) { qlock->lock(type); } | |
376 | + ~QLockHandle() { if (locked()) qlock->unlock(); } | |
377 | + | |
378 | + void lock(QLock::Type type) { qlock->lock(type); } | |
379 | + void unlock() { qlock->unlock(); } | |
380 | + bool locked() const { return qlock->locked(); } | |
381 | + | |
382 | +private: | |
383 | + QLock *qlock; | |
384 | +}; | |
385 | + | |
386 | +#endif // QLOCK_P_H |