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