Ignore:
Timestamp:
Aug 12, 2009, 3:28:29 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Improved wdget create/destroy debug messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r100 r106  
    107107}
    108108
    109 // returns the human readable widget id in the form "name/class".
    110 // used for debugging.
    111 static QString widgetName(HWND hwnd)
     109// Returns a QWidget pointer or 0 if there is no widget corresponding to the
     110// given HWND. As opposed to QWidget::find(), correctly handles WC_FRAME windows
     111// created for top level widgets. Used for debugging.
     112static QWidget *widgetFromId(HWND hwnd)
    112113{
    113114    char buf[10];
     
    115116        if (!strcmp(buf, "#1")) // WC_FRAME
    116117            hwnd = WinWindowFromID(hwnd, FID_CLIENT);
    117         QWidget *w = QWidget::find(hwnd);
    118         if (w)
    119             return QString().sprintf("%s/%s",
    120                                      w->metaObject()->className(),
    121                                      w->objectName().toLocal8Bit().constData());
    122     }
    123     return QLatin1String("<non-Qt-widget>");
     118        return QWidget::find(hwnd);
     119    }
     120    return 0;
     121}
     122
     123// Returns a human readable widget name in the form "class/name".
     124// Used for debugging.
     125static QByteArray widgetName(QWidget *w)
     126{
     127    if (w)
     128        return QString()
     129            .sprintf("%s/%s", w->metaObject()->className(),
     130                     w->objectName().toLocal8Bit().constData()).toLocal8Bit();
     131    return QByteArray("<no-widget>");
    124132}
    125133
     
    160168{
    161169#if defined(QT_DEBUGWIDGETMASK)
    162     qDebug("qt_WinInvalidateRegionEx: hwnd=%08lX (%s) "
     170    qDebug("qt_WinInvalidateRegionEx: hwnd=%08lX "
    163171           "hwndFrom=%08lX hwndTo=%08lX", hwnd,
    164            widgetName(hwnd).toLocal8Bit().constData(),
     172           widgetName().constData(),
    165173           hwndFrom, hwndTo);
    166174#endif
     
    191199        WinQueryWindowPos(child, &swp);
    192200#if defined(QT_DEBUGWIDGETMASK)
    193         qDebug(" child=%08lX [fl=%08lX] (%s)", child, swp.fl,
    194                widgetName(child).toLocal8Bit().constData());
     201        qDebug(" child=%08lX [fl=%08lX] ", child, swp.fl,
     202               widgetName().constData());
    195203#endif
    196204        // proceed only if not hidden
     
    276284
    277285#if defined(QT_DEBUGWIDGETMASK)
    278     qDebug("qt_WinProcessWindowObstacles: hwnd=%08lX (%s), prcl=%p "
     286    qDebug("qt_WinProcessWindowObstacles: hwnd=%08lX , prcl=%p "
    279287           "hrgn=%08lX, op=%ld flags=%08lX", hwnd,
    280            widgetName(hwnd).toLocal8Bit().constData(),
     288           widgetName().constData(),
    281289           prcl, hrgn, op, flags);
    282290#endif
     
    330338                WinQueryWindowPos(relative, &swp);
    331339#if defined(QT_DEBUGWIDGETMASK)
    332                 qDebug(" child=%08lX [fl=%08lX] (%s)", relative, swp.fl,
    333                        widgetName(relative).toLocal8Bit().constData());
     340                qDebug(" child=%08lX [fl=%08lX] ", relative, swp.fl,
     341                       widgetName().constData());
    334342#endif
    335343                // skip if hidden
     
    370378            WinQueryWindowPos(relative, &swp);
    371379#if defined(QT_DEBUGWIDGETMASK)
    372             qDebug(" sibling=%08lX [fl=%08lX] (%s)", relative, swp.fl,
    373                    widgetName(relative).toLocal8Bit().constData());
     380            qDebug(" sibling=%08lX [fl=%08lX] ", relative, swp.fl,
     381                   widgetName().constData());
    374382#endif
    375383            // skip if hidden
     
    420428            WinQueryWindowPos(parent, &swp);
    421429#if defined(QT_DEBUGWIDGETMASK)
    422             qDebug(" parent=%08lX [fl=%08lX] (%s)", parent, swp.fl,
    423                    widgetName(parent).toLocal8Bit().constData());
     430            qDebug(" parent=%08lX [fl=%08lX] ", parent, swp.fl,
     431                   widgetName().constData());
    424432#endif
    425433            delta.x += swp.x;
     
    429437                WinQueryWindowPos(relative, &swp);
    430438#if defined(QT_DEBUGWIDGETMASK)
    431                 qDebug(" ancestor=%08lX [fl=%08lX] (%s)", relative, swp.fl,
    432                        widgetName(parent).toLocal8Bit().constData());
     439                qDebug(" ancestor=%08lX [fl=%08lX] ", relative, swp.fl,
     440                       widgetName().constData());
    433441#endif
    434442                // skip if hidden
     
    480488{
    481489#if defined(QT_DEBUGWIDGETMASK)
    482     qDebug("qt_WinSetWindowPos: hwnd=%08lX (%s) fl=%08lX", hwnd,
    483            widgetName(hwnd).toLocal8Bit().constData(), fl);
     490    qDebug("qt_WinSetWindowPos: hwnd=%08lX fl=%08lX", hwnd,
     491           widgetName().constData(), fl);
    484492#endif
    485493
     
    568576#if defined(QT_DEBUGWIDGETMASK)
    569577        qDebug(" moving up? %ld", up);
    570         qDebug(" hwndFrom=%08lX (%s)", hwndFrom,
    571                widgetName(hwndFrom).toLocal8Bit().constData());
    572         qDebug(" hwndTo=%08lX (%s)", hwndTo,
    573                widgetName(hwndTo).toLocal8Bit().constData());
     578        qDebug(" hwndFrom=%08lX ", hwndFrom,
     579               widgetName().constData());
     580        qDebug(" hwndTo=%08lX ", hwndTo,
     581               widgetName().constData());
    574582#endif
    575583
     
    584592                WinQueryWindowPos(sibling, &swp);
    585593#if defined(QT_DEBUGWIDGETMASK)
    586                 qDebug(" sibling=%08lX [fl=%08lX] (%s)", sibling, swp.fl,
    587                        widgetName(sibling).toLocal8Bit().constData());
     594                qDebug(" sibling=%08lX [fl=%08lX] ", sibling, swp.fl,
     595                       widgetName().constData());
    588596#endif
    589597                // proceed only if not hidden
     
    615623                WinQueryWindowPos(sibling, &swp);
    616624#if defined(QT_DEBUGWIDGETMASK)
    617                 qDebug(" sibling=%08lX [fl=%08lX] (%s)", sibling, swp.fl,
    618                        widgetName(sibling).toLocal8Bit().constData());
     625                qDebug(" sibling=%08lX [fl=%08lX] ", sibling, swp.fl,
     626                       widgetName().constData());
    619627#endif
    620628                // proceed only if not hidden
     
    889897            }
    890898#if defined(QT_DEBUGWINCREATEDESTROY)
    891             qDebug("|Creating top level window (frame) [%s/%s]:\n"
     899            qDebug("|Creating top level window (frame) [%s]:\n"
    892900                   "|  owner = %08lX\n"
    893901                   "|  title = '%s'\n"
    894902                   "|  style = %08lX\n"
    895903                   "|  fcFlags = %08lX",
    896                    q->objectName().toLocal8Bit().constData(),
    897                    q->metaObject()->className(),
    898                    ownerw, title.constData(), fStyle, fcFlags);
     904                   widgetName(q).constData(), ownerw, title.constData(), fStyle,
     905                   fcFlags);
    899906#endif
    900907            fId = WinCreateWindow(HWND_DESKTOP, WC_FRAME, title, fStyle,
     
    918925            // create client window
    919926#if defined(QT_DEBUGWINCREATEDESTROY)
    920             qDebug("|Creating top level window (client) [%s/%s]:\n"
     927            qDebug("|Creating top level window (client) [%s]:\n"
    921928                   "|  owner & parent = %08lX\n"
    922929                   "|  class = '%s'\n"
    923930                   "|  title = '%s'\n"
    924931                   "|  style = %08lX",
    925                    q->objectName().toLocal8Bit().constData(),
    926                    q->metaObject()->className(),
    927                    fId, className.constData(), title.constData(), style);
     932                   widgetName(q).constData(), fId, className.constData(),
     933                   title.constData(), style);
    928934#endif
    929935            // note that we place the client on top (HWND_TOP) to exclude other
     
    933939        } else {
    934940#if defined(QT_DEBUGWINCREATEDESTROY)
    935             qDebug("|Creating top level window (popup) [%s/%s]:\n"
     941            qDebug("|Creating top level window (popup) [%s]:\n"
    936942                   "|  class = '%s'\n"
    937943                   "|  title = '%s'\n"
    938944                   "|  style = %08lX",
    939                    q->objectName().toLocal8Bit().constData(),
    940                    q->metaObject()->className(),
    941                    className.constData(), title.constData(), style);
     945                   widgetName(q).constData(), className.constData(),
     946                   title.constData(), style);
    942947#endif
    943948            id = WinCreateWindow(HWND_DESKTOP, className, title, style,
     
    10471052
    10481053#if defined(QT_DEBUGWINCREATEDESTROY)
    1049         qDebug("|Creating child window [%s/%s]:\n"
     1054        qDebug("|Creating child window [%s]:\n"
    10501055               "|  owner & parent = %08lX\n"
    10511056               "|  class = '%s'\n"
    10521057               "|  title = '%s'\n"
    10531058               "|  style = %08lX",
    1054                q->objectName().toLocal8Bit().constData(),
    1055                q->metaObject()->className(),
    1056                parentw, className.constData(), title.constData(), style);
     1059               widgetName(q).constData(), parentw, className.constData(),
     1060               title.constData(), style);
    10571061#endif
    10581062        id = WinCreateWindow(parentw, className, title, style,
     
    11261130            }
    11271131#if defined(QT_DEBUGWINCREATEDESTROY)
    1128             qDebug("|Destroying window [%s/%s]:\n"
    1129                    "|  hwnd = %08lX",
    1130                    objectName().toLocal8Bit().constData(),
    1131                    metaObject()->className(), id);
     1132            qDebug("|Destroying window [%s]:\n"
     1133                   "|  hwnd = %08lX", widgetName(this).constData(), id);
    11321134#endif
    11331135
Note: See TracChangeset for help on using the changeset viewer.