VirtualBox

Changeset 9677 in vbox


Ignore:
Timestamp:
Jun 13, 2008 10:44:18 AM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: Removed the questionable QLivePointer class.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsDlg.h

    r9674 r9677  
    3434class QWidgetStack;
    3535
    36 /**
    37  *  QObject live pointer class to make alive link of some pointer to
    38  *  some object. It will be nulled in case of object in destroyed.
    39  */
    40 class QLivePointer : public QObject
    41 {
    42     Q_OBJECT;
    43 
    44 public:
    45 
    46     static void link (QWidget *aParent, QWidget **aPointer);
    47     static void kill();
    48 
    49 protected:
    50 
    51     QLivePointer() {}
    52    ~QLivePointer();
    53 
    54 private:
    55 
    56     void setPointer (QWidget **aPointer);
    57 
    58     static QLivePointer *mThis;
    59 
    60     QWidget **mPointer;
    61 };
    62 
    63 class VBoxVMSettingsDlg : public QDialog,
     36class VBoxVMSettingsDlg : public QDialog,
    6437                          public Ui::VBoxVMSettingsDlg
    6538{
    66     Q_OBJECT;
     39    Q_OBJECT
    6740
    6841public:
     
    8255    void updateWhatsThis (bool gotFocus = false);
    8356    void resetFirstRunFlag();
     57    void whatsThisCandidateDestroyed (QObject *aObj = NULL);
    8458
    8559private:
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsDlg.cpp

    r9674 r9677  
    6969}
    7070
    71 /**
    72  *  QObject live pointer class to make alive link of some pointer to some
    73  *  QWidget. It will be nulled in case of linked QWidget is destroyed.
    74  */
    75 QLivePointer* QLivePointer::mThis = 0;
    76 
    77 void QLivePointer::link (QWidget *aParent, QWidget **aPointer)
    78 {
    79     if (!mThis)
    80         mThis = new QLivePointer();
    81     mThis->setParent (aParent);
    82     mThis->setPointer (aPointer);
    83 }
    84 
    85 void QLivePointer::kill()
    86 {
    87     delete mThis;
    88 }
    89 
    90 QLivePointer::~QLivePointer()
    91 {
    92     *mPointer = 0;
    93     mThis = 0;
    94 }
    95 
    96 void QLivePointer::setPointer (QWidget **aPointer)
    97 {
    98     mPointer = aPointer;
    99     *mPointer = static_cast<QWidget*> (parent());
    100 }
    101 
    102 
    10371class VBoxWarnIconLabel: public QWidget
    10472{
     
    12896    , mValid (true)
    12997    , mWhatsThisTimer (new QTimer (this))
    130     , mWhatsThisCandidate (0)
     98    , mWhatsThisCandidate (NULL)
    13199{
    132100    /* Apply UI decorations */
     
    471439}
    472440
     441void VBoxVMSettingsDlg::resetFirstRunFlag()
     442{
     443    if (mAllowResetFirstRunFlag)
     444        mResetFirstRunFlag = true;
     445}
     446
     447void VBoxVMSettingsDlg::whatsThisCandidateDestroyed (QObject *aObj /*= NULL*/)
     448{
     449    /* sanity */
     450    Assert (mWhatsThisCandidate == aObj);
     451
     452    if (mWhatsThisCandidate == aObj)
     453        mWhatsThisCandidate = NULL;
     454}
     455
    473456bool VBoxVMSettingsDlg::eventFilter (QObject *aObject, QEvent *aEvent)
    474457{
     
    486469        {
    487470            if (aEvent->type() == QEvent::Enter)
    488                 QLivePointer::link (widget, &mWhatsThisCandidate);
     471            {
     472                /* What if Qt sends Enter w/o Leave... */
     473                if (mWhatsThisCandidate)
     474                    disconnect (mWhatsThisCandidate, SIGNAL (destroyed (QObject *)),
     475                                this, SLOT (whatsThisCandidateDestroyed (QObject *)));
     476
     477                mWhatsThisCandidate = widget;
     478                /* make sure we don't reference a deleted object after the
     479                 * timer is shot */
     480                connect (mWhatsThisCandidate, SIGNAL (destroyed (QObject *)),
     481                         this, SLOT (whatsThisCandidateDestroyed (QObject *)));
     482            }
    489483            else
    490484            {
    491                 QLivePointer::kill();
    492                 mWhatsThisCandidate = 0;
     485                /* cleanup */
     486                if (mWhatsThisCandidate)
     487                    disconnect (mWhatsThisCandidate, SIGNAL (destroyed (QObject *)),
     488                                this, SLOT (whatsThisCandidateDestroyed (QObject *)));
     489                mWhatsThisCandidate = NULL;
    493490            }
     491
    494492            mWhatsThisTimer->start (100);
    495493            break;
     
    542540}
    543541
    544 void VBoxVMSettingsDlg::resetFirstRunFlag()
    545 {
    546     if (mAllowResetFirstRunFlag)
    547         mResetFirstRunFlag = true;
    548 }
    549 
    550542void VBoxVMSettingsDlg::setWarning (const QString &aWarning)
    551543{
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