Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp	(revision 63832)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp	(revision 63833)
@@ -583,6 +583,8 @@
 void UISnapshotPane::sltCurrentItemChanged(QTreeWidgetItem *pItem)
 {
+    /* Acquire corresponding snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
+
     /* Make the selected item visible: */
-    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
     if (pSnapshotItem)
     {
@@ -644,9 +646,12 @@
 void UISnapshotPane::sltContextMenuRequested(const QPoint &point)
 {
-    /* Search for corresponding snapshot item: */
+    /* Search for corresponding item: */
     const QTreeWidgetItem *pItem = m_pTreeWidget->itemAt(point);
-    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
-    if (!pSnapshotItem)
+    if (!pItem)
         return;
+
+    /* Acquire corresponding snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
+    AssertReturnVoid(pSnapshotItem);
 
     /* Prepare menu: */
@@ -679,8 +684,7 @@
         return;
 
-    /* Make sure snapshot item was changed: */
-    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
-    if (!pSnapshotItem)
-        return;
+    /* Acquire corresponding snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
+    AssertReturnVoid(pSnapshotItem);
 
     /* Rename corresponding snapshot: */
@@ -696,8 +700,7 @@
         return;
 
-    /* Make sure snapshot item was double-clicked: */
-    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
-    if (!pSnapshotItem)
-        return;
+    /* Acquire corresponding snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
+    AssertReturnVoid(pSnapshotItem);
 
     /* Handle Ctrl+DoubleClick: */
@@ -711,6 +714,6 @@
 void UISnapshotPane::sltRestoreSnapshot(bool fSuppressNonCriticalWarnings /* = false */)
 {
-    /* Get currently chosen item: */
-    const SnapshotWgtItem *pSnapshotItem = m_pTreeWidget->currentItem() ? static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()) : 0;
+    /* Acquire currently chosen snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
     AssertReturnVoid(pSnapshotItem);
 
@@ -760,7 +763,6 @@
 void UISnapshotPane::sltDeleteSnapshot()
 {
-    /* Get currently chosen item: */
-    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
-        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
+    /* Acquire currently chosen snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
     AssertReturnVoid(pSnapshotItem);
 
@@ -810,7 +812,6 @@
 void UISnapshotPane::sltShowSnapshotDetails()
 {
-    /* Get currently chosen item: */
-    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
-        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
+    /* Acquire currently chosen snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
     AssertReturnVoid(pSnapshotItem);
 
@@ -830,7 +831,6 @@
 void UISnapshotPane::sltCloneSnapshot()
 {
-    /* Get currently chosen item: */
-    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
-        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
+    /* Acquire currently chosen snapshot item: */
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
     AssertReturnVoid(pSnapshotItem);
 
@@ -1014,11 +1014,10 @@
     /* Remember the selected item and it's first child: */
     QString strSelectedItem, strFirstChildOfSelectedItem;
-    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
-        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
+    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
     if (pSnapshotItem)
     {
         strSelectedItem = pSnapshotItem->snapshotID();
         if (pSnapshotItem->child(0))
-            strFirstChildOfSelectedItem = static_cast<const SnapshotWgtItem*>(pSnapshotItem->child(0))->snapshotID();
+            strFirstChildOfSelectedItem = toSnapshotItem(pSnapshotItem->child(0))->snapshotID();
     }
 
@@ -1083,5 +1082,5 @@
     while (*it)
     {
-        SnapshotWgtItem *pSnapshotItem = static_cast<SnapshotWgtItem*>(*it);
+        SnapshotWgtItem *pSnapshotItem = toSnapshotItem(*it);
         if (pSnapshotItem->snapshotID() == strSnapshotID)
             return pSnapshotItem;
@@ -1130,7 +1129,6 @@
 SnapshotAgeFormat UISnapshotPane::traverseSnapshotAge(QTreeWidgetItem *pItem) const
 {
-    /* Make sure passed root is of valid type: */
-    SnapshotWgtItem *pSnapshotItem = pItem->type() == SnapshotWgtItem::ItemType ?
-                                     static_cast<SnapshotWgtItem*>(pItem) : 0;
+    /* Acquire corresponding snapshot item: */
+    SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
 
     /* Fetch the snapshot age of the root if it's valid: */
@@ -1150,2 +1148,24 @@
 }
 
+/* static  */
+SnapshotWgtItem *UISnapshotPane::toSnapshotItem(QTreeWidgetItem *pItem)
+{
+    /* Make sure alive SnapshotWgtItem passed: */
+    if (!pItem || pItem->type() != SnapshotWgtItem::ItemType)
+        return 0;
+
+    /* Return casted SnapshotWgtItem then: */
+    return static_cast<SnapshotWgtItem*>(pItem);
+}
+
+/* static */
+const SnapshotWgtItem *UISnapshotPane::toSnapshotItem(const QTreeWidgetItem *pItem)
+{
+    /* Make sure alive SnapshotWgtItem passed: */
+    if (!pItem || pItem->type() != SnapshotWgtItem::ItemType)
+        return 0;
+
+    /* Return casted SnapshotWgtItem then: */
+    return static_cast<const SnapshotWgtItem*>(pItem);
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h	(revision 63832)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h	(revision 63833)
@@ -141,4 +141,9 @@
     SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
 
+    /** Casts QTreeWidgetItem to SnapshotWgtItem if possible. */
+    static SnapshotWgtItem *toSnapshotItem(QTreeWidgetItem *pItem);
+    /** Casts const QTreeWidgetItem to const SnapshotWgtItem if possible. */
+    static const SnapshotWgtItem *toSnapshotItem(const QTreeWidgetItem *pItem);
+
     /** Holds the machine COM wrapper. */
     CMachine         m_comMachine;
