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/src/corelib/kernel/qeventdispatcher_glib.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtCore 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
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4343#include "qeventdispatcher_unix_p.h"
    4444
     45
    4546#include <private/qthread_p.h>
    4647
     
    127128    QTimerInfoList timerList;
    128129    QEventLoop::ProcessEventsFlags processEventsFlags;
    129 };
    130 
    131 static gboolean timerSourcePrepare(GSource *source, gint *timeout)
    132 {
    133     gint dummy;
    134     if (!timeout)
    135         timeout = &dummy;
    136 
    137     GTimerSource *src = reinterpret_cast<GTimerSource *>(source);
    138 
     130    bool runWithIdlePriority;
     131};
     132
     133static gboolean timerSourcePrepareHelper(GTimerSource *src, gint *timeout)
     134{
    139135    timeval tv = { 0l, 0l };
    140136    if (!(src->processEventsFlags & QEventLoop::X11ExcludeTimers) && src->timerList.timerWait(tv))
     
    146142}
    147143
    148 static gboolean timerSourceCheck(GSource *source)
    149 {
    150     GTimerSource *src = reinterpret_cast<GTimerSource *>(source);
    151 
     144static gboolean timerSourceCheckHelper(GTimerSource *src)
     145{
    152146    if (src->timerList.isEmpty()
    153147        || (src->processEventsFlags & QEventLoop::X11ExcludeTimers))
     
    160154}
    161155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
    162180static gboolean timerSourceDispatch(GSource *source, GSourceFunc, gpointer)
    163181{
    164     (void) reinterpret_cast<GTimerSource *>(source)->timerList.activateTimers();
     182    GTimerSource *timerSource = reinterpret_cast<GTimerSource *>(source);
     183    timerSource->runWithIdlePriority = true;
     184    (void) timerSource->timerList.activateTimers();
    165185    return true; // ??? don't remove, right again?
    166186}
     
    175195};
    176196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
    177244struct GPostEventSource
    178245{
     
    225292{
    226293    if (qgetenv("QT_NO_THREADED_GLIB").isEmpty()) {
     294
     295
    227296        if (!g_thread_supported())
    228297            g_thread_init(NULL);
     
    233302    } else {
    234303        QCoreApplication *app = QCoreApplication::instance();
    235         if (app && QThread::currentThread() == app->thread()) {
    236             mainContext = g_main_context_default();
    237             g_main_context_ref(mainContext);
    238         } else {
    239             mainContext = g_main_context_new();
    240         }
    241     }
    242 
     304        if (app && QThread::currentThread() == app->thread()) {
     305            mainContext = g_main_context_default();
     306            g_main_context_ref(mainContext);
     307        } else {
     308            mainContext = g_main_context_new();
     309        }
     310    }
     311
     312    // setup post event source
    243313    postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
    244314                                                                        sizeof(GPostEventSource)));
     
    255325    g_source_attach(&socketNotifierSource->source, mainContext);
    256326
    257     // setup timerSource
     327    // setup
    258328    timerSource = reinterpret_cast<GTimerSource *>(g_source_new(&timerSourceFuncs,
    259329                                                                sizeof(GTimerSource)));
    260330    (void) new (&timerSource->timerList) QTimerInfoList();
    261331    timerSource->processEventsFlags = QEventLoop::AllEvents;
     332
    262333    g_source_set_can_recurse(&timerSource->source, true);
    263334    g_source_attach(&timerSource->source, mainContext);
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
    264347}
    265348
     
    269352}
    270353
    271 QEventDispatcherGlib::QEventDispatcherGlib(GMainContext *mainContext,
    272                                            QObject *parent)
    273     : QAbstractEventDispatcher(*(new QEventDispatcherGlibPrivate(mainContext)),
    274                                parent)
    275 {
    276 }
     354QEventDispatcherGlib::QEventDispatcherGlib(GMainContext *mainContext, QObject *parent)
     355    : QAbstractEventDispatcher(*(new QEventDispatcherGlibPrivate(mainContext)), parent)
     356{ }
    277357
    278358QEventDispatcherGlib::~QEventDispatcherGlib()
     
    286366    g_source_unref(&d->timerSource->source);
    287367    d->timerSource = 0;
     368
     369
     370
    288371
    289372    // destroy socket notifier source
     
    321404    QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
    322405    d->timerSource->processEventsFlags = flags;
    323    
     406
     407    if (!(flags & QEventLoop::EventLoopExec)) {
     408        // force timers to be sent at normal priority
     409        d->timerSource->runWithIdlePriority = false;
     410    }
     411
    324412    bool result = g_main_context_iteration(d->mainContext, canWait);
    325413    while (!result && canWait)
    326414        result = g_main_context_iteration(d->mainContext, canWait);
    327    
     415
    328416    d->timerSource->processEventsFlags = savedFlags;
    329417
Note: See TracChangeset for help on using the changeset viewer.