Changeset 63834 in vbox
- Timestamp:
- Sep 14, 2016 1:15:45 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r63833 r63834 27 27 # include <QPointer> 28 28 # include <QApplication> 29 # include <QWriteLocker> 29 30 30 31 /* GUI includes: */ … … 407 408 408 409 409 /** Simple guard block to prevent cyclic call caused by:410 * changing tree-widget item content (rename) leads to snapshot411 * update & snapshot update leads to changing tree-widget item content. */412 class SnapshotEditBlocker413 {414 public:415 416 /** Constructs edit blocker. */417 SnapshotEditBlocker(bool &fProtector) : m_fProtector(fProtector) { m_fProtector = true; }418 /** Destructs edit blocker. */419 virtual ~SnapshotEditBlocker() { m_fProtector = false; }420 421 private:422 423 /** Holds the protector flag reference. */424 bool &m_fProtector;425 };426 427 428 410 UISnapshotPane::UISnapshotPane(QWidget *pParent) 429 411 : QIWithRetranslateUI<QWidget>(pParent) 430 412 , m_pCurrentSnapshotItem(0) 431 , m_fEditProtector(false)432 413 , m_pSnapshotItemActionGroup(new QActionGroup(this)) 433 414 , m_pCurrentStateItemActionGroup(new QActionGroup(this)) … … 680 661 void UISnapshotPane::sltItemChanged(QTreeWidgetItem *pItem) 681 662 { 682 /* Make sure nothing is being edited currently: */683 if ( m_fEditProtector)663 /* Make sure nothing being edited in the meantime: */ 664 if (!m_lockReadWrite.tryLockForWrite()) 684 665 return; 685 666 … … 692 673 if (!comSnapshot.isNull() && comSnapshot.isOk() && comSnapshot.GetName() != pSnapshotItem->text(0)) 693 674 comSnapshot.SetName(pSnapshotItem->text(0)); 675 676 /* Allows editing again: */ 677 m_lockReadWrite.unlock(); 694 678 } 695 679 696 680 void UISnapshotPane::sltItemDoubleClicked(QTreeWidgetItem *pItem) 697 681 { 698 /* Make sure nothing is being edited currently: */699 if (m_fEditProtector)700 return;701 702 682 /* Acquire corresponding snapshot item: */ 703 683 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem); … … 858 838 void UISnapshotPane::sltMachineDataChange(QString strMachineID) 859 839 { 860 /* Prevent snapshot editing in the meantime: */861 SnapshotEditBlocker guardBlock(m_fEditProtector);862 863 840 /* Make sure it's our VM: */ 864 841 if (strMachineID != m_strMachineID) 865 842 return; 866 843 844 /* Prevent snapshot editing in the meantime: */ 845 QWriteLocker locker(&m_lockReadWrite); 846 867 847 /* Recache state current item: */ 868 848 currentStateItem()->recache(); … … 871 851 void UISnapshotPane::sltMachineStateChange(QString strMachineID, KMachineState enmState) 872 852 { 873 /* Prevent snapshot editing in the meantime: */874 SnapshotEditBlocker guardBlock(m_fEditProtector);875 876 853 /* Make sure it's our VM: */ 877 854 if (strMachineID != m_strMachineID) 878 855 return; 879 856 857 /* Prevent snapshot editing in the meantime: */ 858 QWriteLocker locker(&m_lockReadWrite); 859 880 860 /* Recache new machine state: */ 881 861 currentStateItem()->recache(); … … 885 865 void UISnapshotPane::sltSessionStateChange(QString strMachineID, KSessionState enmState) 886 866 { 887 /* Prevent snapshot editing in the meantime: */888 SnapshotEditBlocker guardBlock(m_fEditProtector);889 890 867 /* Make sure it's our VM: */ 891 868 if (strMachineID != m_strMachineID) 892 869 return; 870 871 /* Prevent snapshot editing in the meantime: */ 872 QWriteLocker locker(&m_lockReadWrite); 893 873 894 874 /* Recache new session state: */ … … 1003 983 { 1004 984 /* Prevent snapshot editing in the meantime: */ 1005 SnapshotEditBlocker guardBlock(m_fEditProtector);985 QWriteLocker locker(&m_lockReadWrite); 1006 986 1007 987 /* If VM is null, just updated the current itm: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r63833 r63834 22 22 #include <QTimer> 23 23 #include <QIcon> 24 #include <QReadWriteLock> 24 25 25 26 /* GUI includes: */ … … 155 156 SnapshotWgtItem *m_pCurrentSnapshotItem; 156 157 /** Holds the snapshot item editing protector. */ 157 bool m_fEditProtector;158 QReadWriteLock m_lockReadWrite; 158 159 159 160 /** Holds the snapshot item action group instance. */
Note:
See TracChangeset
for help on using the changeset viewer.