Changeset 9677 in vbox
- Timestamp:
- Jun 13, 2008 10:44:18 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 2 edited
-
include/VBoxVMSettingsDlg.h (modified) (2 diffs)
-
src/VBoxVMSettingsDlg.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsDlg.h
r9674 r9677 34 34 class QWidgetStack; 35 35 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, 36 class VBoxVMSettingsDlg : public QDialog, 64 37 public Ui::VBoxVMSettingsDlg 65 38 { 66 Q_OBJECT ;39 Q_OBJECT 67 40 68 41 public: … … 82 55 void updateWhatsThis (bool gotFocus = false); 83 56 void resetFirstRunFlag(); 57 void whatsThisCandidateDestroyed (QObject *aObj = NULL); 84 58 85 59 private: -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsDlg.cpp
r9674 r9677 69 69 } 70 70 71 /**72 * QObject live pointer class to make alive link of some pointer to some73 * 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 103 71 class VBoxWarnIconLabel: public QWidget 104 72 { … … 128 96 , mValid (true) 129 97 , mWhatsThisTimer (new QTimer (this)) 130 , mWhatsThisCandidate ( 0)98 , mWhatsThisCandidate (NULL) 131 99 { 132 100 /* Apply UI decorations */ … … 471 439 } 472 440 441 void VBoxVMSettingsDlg::resetFirstRunFlag() 442 { 443 if (mAllowResetFirstRunFlag) 444 mResetFirstRunFlag = true; 445 } 446 447 void VBoxVMSettingsDlg::whatsThisCandidateDestroyed (QObject *aObj /*= NULL*/) 448 { 449 /* sanity */ 450 Assert (mWhatsThisCandidate == aObj); 451 452 if (mWhatsThisCandidate == aObj) 453 mWhatsThisCandidate = NULL; 454 } 455 473 456 bool VBoxVMSettingsDlg::eventFilter (QObject *aObject, QEvent *aEvent) 474 457 { … … 486 469 { 487 470 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 } 489 483 else 490 484 { 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; 493 490 } 491 494 492 mWhatsThisTimer->start (100); 495 493 break; … … 542 540 } 543 541 544 void VBoxVMSettingsDlg::resetFirstRunFlag()545 {546 if (mAllowResetFirstRunFlag)547 mResetFirstRunFlag = true;548 }549 550 542 void VBoxVMSettingsDlg::setWarning (const QString &aWarning) 551 543 {
Note:
See TracChangeset
for help on using the changeset viewer.

