VirtualBox

Changeset 43126 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 30, 2012 7:22:02 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM settings stuff: Protect widget validator with Qt safe-pointer stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/extensions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIWidgetValidator.cpp

    r28800 r43126  
    153153    foreach (Watched watched, mWatched)
    154154    {
    155         if (watched.widget->inherits ("QLineEdit"))
    156         {
    157             QLineEdit *le = ((QLineEdit *) watched.widget);
     155        if (QLineEdit *le = qobject_cast<QLineEdit*>(watched.widget))
     156        {
    158157            Assert (le->validator());
    159158            if (!le->validator() || !le->isEnabled())
     
    163162            state = le->validator()->validate (text, pos);
    164163        }
    165         else if (watched.widget->inherits ("QComboBox"))
    166         {
    167             QComboBox *cb = ((QComboBox *) watched.widget);
     164        else if (QComboBox *cb = qobject_cast<QComboBox*>(watched.widget))
     165        {
    168166            Assert (cb->validator());
    169167            if (!cb->validator() || !cb->isEnabled())
     
    299297            /* Remove '&' symbol from the buddy field name */
    300298            title = VBoxGlobal::
    301                 removeAccelMark (((QLabel *) mLastInvalid.buddy)->text());
     299                removeAccelMark(qobject_cast<QLabel*>(mLastInvalid.buddy)->text());
    302300
    303301            /* Remove ':' symbol from the buddy field name */
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIWidgetValidator.h

    r28800 r43126  
    2626#include <QValidator>
    2727#include <QList>
     28#include <QPointer>
    2829
    2930class QIWidgetValidator : public QObject
     
    7273    {
    7374        Watched()
    74             : widget (NULL), buddy (NULL)
    75             , state (QValidator::Acceptable) {}
     75            : state (QValidator::Acceptable) {}
    7676
    77         QWidget *widget;
    78         QWidget *buddy;
     77        QPointer<QWidget> widget;
     78        QPointer<QWidget> buddy;
    7979        QValidator::State state;
    8080    };
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette