Changeset 83
- Timestamp:
- Jul 24, 2009, 2:31:38 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/kernel/qeventdispatcher_pm.cpp
r67 r83 46 46 #include "qcoreapplication.h" 47 47 #include "qhash.h" 48 #include "qlibrary.h"49 #include "qpair.h"50 #include "qset.h"51 48 #include "qsocketnotifier.h" 52 #include "qvarlengtharray.h" 49 #include "qmutex.h" 50 #include "qwaitcondition.h" 53 51 54 52 #include "qabstracteventdispatcher_p.h" … … 59 57 60 58 #include <Qt/qwindowdefs_pm.h> // for QPMObjectWindow declaration 59 60 61 61 62 62 QT_BEGIN_NAMESPACE … … 152 152 */ 153 153 154 /// @todo remove?155 // returns HMQ of the current thread or NULL if no event queue has been created156 static HMQ qt_WinQueryQueue(HAB hab)157 {158 PTIB ptib;159 PPIB ppib;160 DosGetInfoBlocks(&ptib, &ppib);161 return WinQueueFromID(hab, ppib->pib_ulpid, ptib->tib_ptib2->tib2_ultid);162 }163 164 154 /*! 165 155 Constructs a new object window for the current thread. … … 263 253 264 254 /*! 265 \fn QPMObjectWindow::send(ULONG msg, MPARAM mp1, MPARAM mp2) const266 267 Synchronously sends a message \a msg with the given parameters \a mp1 and268 \a mp2 to this window handle and returns a reply from the message() function.269 270 \note Must be called on the same thread that cosnstructed this instance.255 \fn QPMObjectWindow::send(ULONG msg, MPARAM mp1, MPARAM mp2) const 256 257 Synchronously sends a message \a msg with the given parameters \a mp1 and 258 \a mp2 to this window handle and returns a reply from the message() function. 259 260 \note Must be called on the same thread that cosnstructed this instance. 271 261 */ 272 262 273 263 /*! 274 \fn QPMObjectWindow::post(ULONG msg, MPARAM mp1, MPARAM mp2) const275 276 Asynchronously posts a message \a msg with the given parameters \a mp1 and277 \a mp2 to this window handle. Returns \c TRUE on success and \c FALSE278 otherwise.279 280 \note Can be called on any thread.264 \fn QPMObjectWindow::post(ULONG msg, MPARAM mp1, MPARAM mp2) const 265 266 Asynchronously posts a message \a msg with the given parameters \a mp1 and 267 268 otherwise. 269 270 \note Can be called on any thread. 281 271 */ 272 282 273 283 274 // socket select notification (highest priority) … … 285 276 // zero timer notification (lowest priority) 286 277 #define WM_U_SEM_ZEROTIMER WM_SEM4 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 287 584 288 585 class QEventDispatcherPMPrivate : public QAbstractEventDispatcherPrivate … … 318 615 319 616 // @todo later 320 // DWORD threadId;321 //322 // bool interrupt;323 //324 // // internal window handle used for socketnotifiers/timers/etc325 // HWND internalHwnd;326 617 // 327 618 // // timers … … 331 622 // void unregisterTimer(WinTimerInfo *t); 332 623 // void sendTimerEvent(int timerId); 333 //334 // // socket notifiers335 // QSNDict sn_read;336 // QSNDict sn_write;337 // QSNDict sn_except;338 // void doWsaAsyncSelect(int socket);339 624 // 340 625 // QList<QMSG> queuedUserInputEvents; … … 399 684 switch (msg) { 400 685 case WM_U_SEM_SELECT: { 401 // @todo later 402 // if (eventLoop) 403 // eventLoop->activateSocketNotifiers(); 686 QSocketNotifier *notifier = 687 QSockSelectThread::getSocketNotifier(LONGFROMMP(mp1)); 688 if (notifier) { 689 QEvent event(QEvent::SockAct); 690 QCoreApplication::sendEvent(notifier, &event); 691 } 404 692 break; 405 693 } … … 575 863 } 576 864 577 void QEventDispatcherPMPrivate::doWsaAsyncSelect(int socket)578 {579 Q_ASSERT(internalHwnd);580 int sn_event = 0;581 if (sn_read.contains(socket))582 sn_event |= FD_READ | FD_CLOSE | FD_ACCEPT;583 if (sn_write.contains(socket))584 sn_event |= FD_WRITE | FD_CONNECT;585 if (sn_except.contains(socket))586 sn_event |= FD_OOB;587 // BoundsChecker may emit a warning for WSAAsyncSelect when sn_event == 0588 // This is a BoundsChecker bug and not a Qt bug589 WSAAsyncSelect(socket, internalHwnd, sn_event ? WM_USER : 0, sn_event);590 }591 592 865 void QEventDispatcherPM::createInternalHwnd() 593 866 { … … 624 897 bool QEventDispatcherPM::processEvents(QEventLoop::ProcessEventsFlags flags) 625 898 { 626 Q_D(QEventDispatcherPM);627 628 899 // @todo later 629 900 #if 0 901 902 630 903 if (!d->internalHwnd) 631 904 createInternalHwnd(); … … 732 1005 void QEventDispatcherPM::registerSocketNotifier(QSocketNotifier *notifier) 733 1006 { 734 // @todo later735 #if 0736 1007 Q_ASSERT(notifier); 1008 737 1009 int sockfd = notifier->socket(); 738 int type = notifier->type(); 739 #ifndef QT_NO_DEBUG 740 if (sockfd < 0) { 1010 if (sockfd < 0 1011 || unsigned(sockfd) >= FD_SETSIZE) { 741 1012 qWarning("QSocketNotifier: Internal error"); 742 1013 return; 743 } else if (notifier->thread() != thread() || thread() != QThread::currentThread()) { 1014 } else if (notifier->thread() != thread() 1015 || thread() != QThread::currentThread()) { 744 1016 qWarning("QSocketNotifier: socket notifiers cannot be enabled from another thread"); 745 1017 return; … … 748 1020 749 1021 Q_D(QEventDispatcherPM); 750 QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; 751 QSNDict *dict = sn_vec[type]; 752 753 if (QCoreApplication::closingDown()) // ### d->exitloop? 754 return; // after sn_cleanup, don't reinitialize. 755 756 if (dict->contains(sockfd)) { 757 const char *t[] = { "Read", "Write", "Exception" }; 758 /* Variable "socket" below is a function pointer. */ 759 qWarning("QSocketNotifier: Multiple socket notifiers for " 760 "same socket %d and type %s", sockfd, t[type]); 761 } 762 763 QSockNot *sn = new QSockNot; 764 sn->obj = notifier; 765 sn->fd = sockfd; 766 dict->insert(sn->fd, sn); 767 768 if (d->internalHwnd) 769 d->doWsaAsyncSelect(sockfd); 770 #endif 1022 d->createAuxWnd(); 1023 1024 QSockSelectThread::addSelect(notifier, d->auxWnd.hwnd()); 771 1025 } 772 1026 773 1027 void QEventDispatcherPM::unregisterSocketNotifier(QSocketNotifier *notifier) 774 1028 { 775 // @todo later776 #if 0777 1029 Q_ASSERT(notifier); 1030 778 1031 int sockfd = notifier->socket(); 779 int type = notifier->type(); 780 #ifndef QT_NO_DEBUG 781 if (sockfd < 0) { 1032 if (sockfd < 0 1033 || unsigned(sockfd) >= FD_SETSIZE) { 782 1034 qWarning("QSocketNotifier: Internal error"); 783 1035 return; 784 } else if (notifier->thread() != thread() || thread() != QThread::currentThread()) { 1036 } else if (notifier->thread() != thread() 1037 || thread() != QThread::currentThread()) { 785 1038 qWarning("QSocketNotifier: socket notifiers cannot be disabled from another thread"); 786 1039 return; … … 788 1041 #endif 789 1042 790 Q_D(QEventDispatcherPM); 791 QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; 792 QSNDict *dict = sn_vec[type]; 793 QSockNot *sn = dict->value(sockfd); 794 if (!sn) 795 return; 796 797 dict->remove(sockfd); 798 delete sn; 799 800 if (d->internalHwnd) 801 d->doWsaAsyncSelect(sockfd); 802 #endif 1043 QSockSelectThread::removeSelect(notifier); 803 1044 } 804 1045 … … 944 1185 void QEventDispatcherPM::startingUp() 945 1186 { 1187 946 1188 } 947 1189 948 1190 void QEventDispatcherPM::closingDown() 949 1191 { 950 Q _D(QEventDispatcherPM);1192 Q); 951 1193 952 1194 // @todo remove later 953 1195 #if 0 954 // clean up any socketnotifiers 955 while (!d->sn_read.isEmpty()) 956 unregisterSocketNotifier((*(d->sn_read.begin()))->obj); 957 while (!d->sn_write.isEmpty()) 958 unregisterSocketNotifier((*(d->sn_write.begin()))->obj); 959 while (!d->sn_except.isEmpty()) 960 unregisterSocketNotifier((*(d->sn_except.begin()))->obj); 1196 Q_D(QEventDispatcherPM); 961 1197 962 1198 // clean up any timers
Note:
See TracChangeset
for help on using the changeset viewer.