Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/qvfb/qlock.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4242#include "qlock_p.h"
    4343
    44 #ifndef QT_NO_QWS_MULTIPROCESS
     44
     45#ifdef QT_NO_QWS_MULTIPROCESS
     46
     47QT_BEGIN_NAMESPACE
     48
     49/* no multiprocess - use a dummy */
     50
     51QLock::QLock(const QString & /*filename*/, char /*id*/, bool /*create*/)
     52    : type(Read), data(0)
     53{
     54}
     55
     56QLock::~QLock()
     57{
     58}
     59
     60bool QLock::isValid() const
     61{
     62    return true;
     63}
     64
     65void QLock::lock(Type t)
     66{
     67    data = (QLockData *)-1;
     68    type = t;
     69}
     70
     71void QLock::unlock()
     72{
     73    data = 0;
     74}
     75
     76bool QLock::locked() const
     77{
     78    return data;
     79}
     80
     81QT_END_NAMESPACE
     82
     83#else // QT_NO_QWS_MULTIPROCESS
    4584
    4685#include "qwssignalhandler_p.h"
     86
    4787#include <unistd.h>
    4888#include <sys/types.h>
     
    72112#include <signal.h>
    73113
    74 #endif // QT_NO_QWS_MULTIPROCESS
     114#include <private/qcore_unix_p.h> // overrides QT_OPEN
     115
     116
     117QT_BEGIN_NAMESPACE
    75118
    76119#define MAX_LOCKS   200            // maximum simultaneous read locks
    77120
    78 QT_BEGIN_NAMESPACE
    79 
    80 
    81 #ifndef QT_NO_QWS_MULTIPROCESS
    82121class QLockData
    83122{
     
    90129    bool owned;
    91130};
    92 #endif // QT_NO_QWS_MULTIPROCESS
    93131
    94132/*!
     
    97135
    98136    \ingroup qws
    99     \ingroup io
    100137
    101138    \internal
     
    125162QLock::QLock(const QString &filename, char id, bool create)
    126163{
    127 #ifdef QT_NO_QWS_MULTIPROCESS
    128     Q_UNUSED(filename);
    129     Q_UNUSED(id);
    130     Q_UNUSED(create);
    131 #else
    132164    data = new QLockData;
    133165    data->count = 0;
     
    135167    data->file = QString(filename+id).toLocal8Bit().constData();
    136168    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);
    138170        if(data->id != -1 || !create) {
    139171            data->owned = x;
     
    162194        qDebug() << "Error" << eno << strerror(eno);
    163195    }
    164 #endif
    165196}
    166197
     
    173204QLock::~QLock()
    174205{
    175 #ifndef QT_NO_QWS_MULTIPROCESS
    176206    if (locked())
    177207        unlock();
    178208#ifdef Q_NO_SEMAPHORE
    179209    if(isValid()) {
    180         close(data->id);
     210        QT_CLOSE(data->id);
    181211        if(data->owned)
    182212            unlink(data->file);
     
    187217#endif
    188218    delete data;
    189 #endif
    190219}
    191220
     
    199228bool QLock::isValid() const
    200229{
    201 #ifndef QT_NO_QWS_MULTIPROCESS
    202230    return (data->id != -1);
    203 #else
    204     return true;
    205 #endif
    206231}
    207232
     
    220245void QLock::lock(Type t)
    221246{
    222 #ifdef QT_NO_QWS_MULTIPROCESS
    223     Q_UNUSED(t);
    224 #else
    225247    if (!data->count) {
    226248#ifdef Q_NO_SEMAPHORE
     
    255277    }
    256278    data->count++;
    257 #endif
    258279}
    259280
     
    268289void QLock::unlock()
    269290{
    270 #ifndef QT_NO_QWS_MULTIPROCESS
    271291    if(data->count) {
    272292        data->count--;
     
    297317        qDebug("Unlock without corresponding lock");
    298318    }
    299 #endif
    300319}
    301320
     
    309328bool QLock::locked() const
    310329{
    311 #ifndef QT_NO_QWS_MULTIPROCESS
    312330    return (data->count > 0);
    313 #else
    314     return false;
    315 #endif
    316331}
    317332
    318333QT_END_NAMESPACE
     334
     335#endif // QT_NO_QWS_MULTIPROCESS
     336
Note: See TracChangeset for help on using the changeset viewer.