Changeset 153 for trunk


Ignore:
Timestamp:
Nov 13, 2006, 12:05:13 AM (19 years ago)
Author:
dmik
Message:

kernel: Attempted to fix some spontaneous Qt application traps during window management (seen in Psi a couple of times after showing big tool tips, see ticket:34 for more info):

  • Deleted modal widgets could be left referenced by widgets they were blocking (through the QWL_QTMODAL window word).
  • Custom window data was not initialized to zero after window creation.
Location:
trunk/src/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel/qapplication_pm.cpp

    r139 r153  
    17991799                // get the modal widget that made this window blocked
    18001800                QWidget *m =
    1801                     (QWidget*) WinQueryWindowULong( widget->winId(), QWL_QTMODAL );
     1801                    (QWidget*) WinQueryWindowPtr( widget->winId(), QWL_QTMODAL );
    18021802                if( m ) {
    18031803                    if ( swp.fl & SWP_ACTIVATE ) {
     
    19701970            }
    19711971            QWidget *blockedBy =
    1972                 (QWidget*) WinQueryWindowULong( w->winId(), QWL_QTMODAL );
     1972                (QWidget*) WinQueryWindowPtr( w->winId(), QWL_QTMODAL );
    19731973            if ( blocked ) {
    19741974                // stop sending on alreay blocked widgets
     
    19801980                    return;
    19811981            }
    1982             WinSetWindowULong( w->winId(), QWL_QTMODAL,
    1983                     blocked ? (ULONG) modal : 0 );
     1982            WinSetWindowPtr( w->winId(), QWL_QTMODAL, blocked ? modal : NULL );
    19841983            WinEnableWindow( w->winFId(), !blocked );
    19851984        }
     
    19931992        while( ( o = it.current() ) != 0 ) {
    19941993            ++it;
    1995             qt_sendBlocked( o, modal, e, FALSE );
     1994            qt_sendBlocked( o, modal, e, blocked ? FALSE : TRUE );
    19961995        }
    19971996    }
     
    20172016    QEvent e( blocked ? QEvent::WindowBlocked : QEvent::WindowUnblocked );
    20182017
     2018    if ( !blocked ) {
     2019        // For unblocking, we go through all top-level widgets and unblock
     2020        // those that have been blocked by the given modal widget. It means that
     2021        // we don't select widgets to unblock based on widget flags (as we do
     2022        // below when blocking) because these flags might have been changed
     2023        // so that we could skip widgets that we would have to unblock. Although
     2024        // normally widget flags should never be changed after widget creation
     2025        // (except that by QWidget::reparentSys() that takes blocking into
     2026        // account and corrects it as needed), nothing stops one from doing so,
     2027        // leading to a case when the QWL_QTMODAL word of some widget still
     2028        // points to a widget that has been deleted (so that any attempt to
     2029        // access it results into a nasty segfault).
     2030        QWidgetList *list = QApplication::topLevelWidgets();
     2031        for( QWidget *w = list->first(); w; w = list->next() ) {
     2032            if ( WinQueryWindowPtr( w->winId(), QWL_QTMODAL ) == modal )
     2033                qt_sendBlocked( w, modal, &e, TRUE );
     2034        }
     2035        delete list;
     2036        return;
     2037    }
     2038   
    20192039    // find the modal's group leader
    20202040    QWidget *mgl = modal->parentWidget();
     
    20302050    for( QWidget *w = list->first(); w; w = list->next() ) {
    20312051        if (
    2032             !w->isDesktop() && !w->isPopup() && !w->isHidden() &&
     2052            !w->isDesktop() && !w->isPopup() &&
    20332053            !w->testWFlags( Qt::WGroupLeader ) &&
    20342054            (!w->parentWidget() || w->parentWidget()->isDesktop())
     
    20452065    // qt_tryModalHelper() also assumes that the toppest modal widget blocks
    20462066    // other modals, regardless of WGroupLeader flags in parents. do the same.
    2047     // note: the given modal is not yet at the stack here.
     2067    // Note: the given modal is not yet at the stack here.
    20482068    if ( qt_modal_stack ) {
    20492069        QWidget *m = qt_modal_stack->first();
  • trunk/src/kernel/qwidget_pm.cpp

    r135 r153  
    941941*/
    942942
     943        // strictly speaking, PM is not obliged to initialize window data
     944        // with zeroes (although seems to), so do it ourselves
     945        for ( LONG i = 0; i <= QT_EXTRAWINDATASIZE - 4; i += 4 )
     946            WinSetWindowULong( id, i, 0 );
     947
    943948        // When the FS_SHELLPOSITION flag is specified during WC_FRAME window
    944949        // creation its size and position remains zero until it is shown
     
    10831088    QWidget *blockedBy = 0;
    10841089    if ( isTopLevel() )
    1085         blockedBy = (QWidget*) WinQueryWindowULong( winId(), QWL_QTMODAL );
     1090        blockedBy = (QWidget*) WinQueryWindowPtr( winId(), QWL_QTMODAL );
    10861091    if ( !blockedBy && parentWidget() )
    1087         blockedBy = (QWidget*) WinQueryWindowULong(
     1092        blockedBy = (QWidget*) WinQueryWindowPtr(
    10881093            parentWidget()->topLevelWidget()->winId(), QWL_QTMODAL );
    10891094    if ( blockedBy ) {
     
    11511156    blockedBy = 0;
    11521157    if ( parentWidget() )
    1153         blockedBy = (QWidget*) WinQueryWindowULong(
     1158        blockedBy = (QWidget*) WinQueryWindowPtr(
    11541159            parentWidget()->topLevelWidget()->winId(), QWL_QTMODAL );
    11551160    if ( blockedBy ) {
Note: See TracChangeset for help on using the changeset viewer.