Changeset 561 for trunk/src/corelib/kernel/qeventdispatcher_glib.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/src/corelib/kernel/qeventdispatcher_glib.cpp
r2 r561 2 2 ** 3 3 ** 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]) 5 6 ** 6 7 ** This file is part of the QtCore 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 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 43 43 #include "qeventdispatcher_unix_p.h" 44 44 45 45 46 #include <private/qthread_p.h> 46 47 … … 127 128 QTimerInfoList timerList; 128 129 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 133 static gboolean timerSourcePrepareHelper(GTimerSource *src, gint *timeout) 134 { 139 135 timeval tv = { 0l, 0l }; 140 136 if (!(src->processEventsFlags & QEventLoop::X11ExcludeTimers) && src->timerList.timerWait(tv)) … … 146 142 } 147 143 148 static gboolean timerSourceCheck(GSource *source) 149 { 150 GTimerSource *src = reinterpret_cast<GTimerSource *>(source); 151 144 static gboolean timerSourceCheckHelper(GTimerSource *src) 145 { 152 146 if (src->timerList.isEmpty() 153 147 || (src->processEventsFlags & QEventLoop::X11ExcludeTimers)) … … 160 154 } 161 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 162 180 static gboolean timerSourceDispatch(GSource *source, GSourceFunc, gpointer) 163 181 { 164 (void) reinterpret_cast<GTimerSource *>(source)->timerList.activateTimers(); 182 GTimerSource *timerSource = reinterpret_cast<GTimerSource *>(source); 183 timerSource->runWithIdlePriority = true; 184 (void) timerSource->timerList.activateTimers(); 165 185 return true; // ??? don't remove, right again? 166 186 } … … 175 195 }; 176 196 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 177 244 struct GPostEventSource 178 245 { … … 225 292 { 226 293 if (qgetenv("QT_NO_THREADED_GLIB").isEmpty()) { 294 295 227 296 if (!g_thread_supported()) 228 297 g_thread_init(NULL); … … 233 302 } else { 234 303 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 243 313 postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs, 244 314 sizeof(GPostEventSource))); … … 255 325 g_source_attach(&socketNotifierSource->source, mainContext); 256 326 257 // setup timerSource327 // setup 258 328 timerSource = reinterpret_cast<GTimerSource *>(g_source_new(&timerSourceFuncs, 259 329 sizeof(GTimerSource))); 260 330 (void) new (&timerSource->timerList) QTimerInfoList(); 261 331 timerSource->processEventsFlags = QEventLoop::AllEvents; 332 262 333 g_source_set_can_recurse(&timerSource->source, true); 263 334 g_source_attach(&timerSource->source, mainContext); 335 336 337 338 339 340 341 342 343 344 345 346 264 347 } 265 348 … … 269 352 } 270 353 271 QEventDispatcherGlib::QEventDispatcherGlib(GMainContext *mainContext, 272 QObject *parent) 273 : QAbstractEventDispatcher(*(new QEventDispatcherGlibPrivate(mainContext)), 274 parent) 275 { 276 } 354 QEventDispatcherGlib::QEventDispatcherGlib(GMainContext *mainContext, QObject *parent) 355 : QAbstractEventDispatcher(*(new QEventDispatcherGlibPrivate(mainContext)), parent) 356 { } 277 357 278 358 QEventDispatcherGlib::~QEventDispatcherGlib() … … 286 366 g_source_unref(&d->timerSource->source); 287 367 d->timerSource = 0; 368 369 370 288 371 289 372 // destroy socket notifier source … … 321 404 QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags; 322 405 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 324 412 bool result = g_main_context_iteration(d->mainContext, canWait); 325 413 while (!result && canWait) 326 414 result = g_main_context_iteration(d->mainContext, canWait); 327 415 328 416 d->timerSource->processEventsFlags = savedFlags; 329 417
Note:
See TracChangeset
for help on using the changeset viewer.