Index: trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp	(revision 65686)
+++ trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp	(revision 65687)
@@ -393,5 +393,4 @@
     : m_pActionAddNetworkNAT(0), m_pActionDelNetworkNAT(0), m_pActionEditNetworkNAT(0)
     , m_pActionAddNetworkHost(0), m_pActionDelNetworkHost(0), m_pActionEditNetworkHost(0)
-    , m_fChanged(false)
 {
     /* Apply UI decorations: */
@@ -517,14 +516,19 @@
     UISettingsPageGlobal::fetchData(data);
 
-    /* Load to cache: */
-    m_cache.m_networksNAT.clear();
-    const CNATNetworkVector &networks = vboxGlobal().virtualBox().GetNATNetworks();
-    foreach (const CNATNetwork &network, networks)
-        m_cache.m_networksNAT << generateDataNetworkNAT(network);
-    m_cache.m_networksHost.clear();
-    const CHostNetworkInterfaceVector &interfaces = vboxGlobal().host().GetNetworkInterfaces();
-    foreach (const CHostNetworkInterface &iface, interfaces)
+    /* Clear cache initially: */
+    m_cache.clear();
+
+    /* Prepare old data: */
+    UIDataSettingsGlobalNetwork oldData;
+
+    /* Gather old data: */
+    foreach (const CNATNetwork &network, vboxGlobal().virtualBox().GetNATNetworks())
+        oldData.m_networksNAT << generateDataNetworkNAT(network);
+    foreach (const CHostNetworkInterface &iface, vboxGlobal().host().GetNetworkInterfaces())
         if (iface.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly)
-            m_cache.m_networksHost << generateDataNetworkHost(iface);
+            oldData.m_networksHost << generateDataNetworkHost(iface);
+
+    /* Cache old data: */
+    m_cache.cacheInitialData(oldData);
 
     /* Upload properties & settings to data: */
@@ -534,11 +538,14 @@
 void UIGlobalSettingsNetwork::getFromCache()
 {
-    /* Fetch from cache: */
-    foreach (const UIDataSettingsGlobalNetworkNAT &network, m_cache.m_networksNAT)
+    /* Get old data from cache: */
+    const UIDataSettingsGlobalNetwork &oldData = m_cache.base();
+
+    /* Load old data from cache: */
+    foreach (const UIDataSettingsGlobalNetworkNAT &network, oldData.m_networksNAT)
         createTreeItemNetworkNAT(network);
     m_pTreeNetworkNAT->sortByColumn(1, Qt::AscendingOrder);
     m_pTreeNetworkNAT->setCurrentItem(m_pTreeNetworkNAT->topLevelItem(0));
     sltHandleCurrentItemChangeNetworkNAT();
-    foreach (const UIDataSettingsGlobalNetworkHost &network, m_cache.m_networksHost)
+    foreach (const UIDataSettingsGlobalNetworkHost &network, oldData.m_networksHost)
         createTreeItemNetworkHost(network);
     m_pTreeNetworkHost->sortByColumn(0, Qt::AscendingOrder);
@@ -552,6 +559,9 @@
 void UIGlobalSettingsNetwork::putToCache()
 {
-    /* Upload to cache: */
-    m_cache.m_networksNAT.clear();
+    /* Prepare new data: */
+    UIDataSettingsGlobalNetwork newData = m_cache.base();
+
+    /* Gather new data: */
+    newData.m_networksNAT.clear();
     for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkNAT->topLevelItemCount(); ++iNetworkIndex)
     {
@@ -559,7 +569,7 @@
         UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(iNetworkIndex));
         pItem->uploadNetworkData(data);
-        m_cache.m_networksNAT << data;
-    }
-    m_cache.m_networksHost.clear();
+        newData.m_networksNAT << data;
+    }
+    newData.m_networksHost.clear();
     for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkHost->topLevelItemCount(); ++iNetworkIndex)
     {
@@ -567,22 +577,26 @@
         UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->topLevelItem(iNetworkIndex));
         pItem->uploadNetworkData(data);
-        m_cache.m_networksHost << data;
-    }
+        newData.m_networksHost << data;
+    }
+
+    /* Cache new data: */
+    m_cache.cacheCurrentData(newData);
 }
 
 void UIGlobalSettingsNetwork::saveFromCacheTo(QVariant &data)
 {
-    /* Ensure settings were changed: */
-    if (!m_fChanged)
-        return;
-
     /* Fetch data to properties & settings: */
     UISettingsPageGlobal::fetchData(data);
 
-    /* Save from cache: */
-    foreach (const UIDataSettingsGlobalNetworkNAT &data, m_cache.m_networksNAT)
-        saveCacheItemNetworkNAT(data);
-    foreach (const UIDataSettingsGlobalNetworkHost &data, m_cache.m_networksHost)
-        saveCacheItemNetworkHost(data);
+    /* Save new data from cache: */
+    if (m_cache.wasChanged())
+    {
+        if (m_cache.data().m_networksNAT != m_cache.base().m_networksNAT)
+            foreach (const UIDataSettingsGlobalNetworkNAT &data, m_cache.data().m_networksNAT)
+                saveCacheItemNetworkNAT(data);
+        if (m_cache.data().m_networksHost != m_cache.base().m_networksHost)
+            foreach (const UIDataSettingsGlobalNetworkHost &data, m_cache.data().m_networksHost)
+                saveCacheItemNetworkHost(data);
+    }
 
     /* Upload properties & settings to data: */
@@ -783,5 +797,4 @@
         pItem->fetchNetworkData(data);
         sltHandleCurrentItemChangeNetworkNAT();
-        m_fChanged = true;
         /* Revalidate: */
         revalidate();
@@ -797,5 +810,4 @@
     /* Update item data: */
     pItem->updateData();
-    m_fChanged = true;
 }
 
@@ -887,5 +899,4 @@
         pItem->fetchNetworkData(data);
         sltHandleCurrentItemChangeNetworkHost();
-        m_fChanged = true;
         /* Revalidate: */
         revalidate();
Index: trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h	(revision 65686)
+++ trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h	(revision 65687)
@@ -29,9 +29,22 @@
 
 
-/** Global settings: Network page: NAT network cache structure. */
+/** Global settings: Network page: NAT network data structure. */
 struct UIDataSettingsGlobalNetworkNAT
 {
-    /** Returns whether the @a other passed data is equal to this one. */
-    bool operator==(const UIDataSettingsGlobalNetworkNAT &other) const
+    /** Constructs data. */
+    UIDataSettingsGlobalNetworkNAT()
+        : m_fEnabled(false)
+        , m_strName(QString())
+        , m_strNewName(QString())
+        , m_strCIDR(QString())
+        , m_fSupportsDHCP(false)
+        , m_fSupportsIPv6(false)
+        , m_fAdvertiseDefaultIPv6Route(false)
+        , m_ipv4rules(QList<UIPortForwardingData>())
+        , m_ipv6rules(QList<UIPortForwardingData>())
+    {}
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool equal(const UIDataSettingsGlobalNetworkNAT &other) const
     {
         return true
@@ -47,4 +60,9 @@
                ;
     }
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool operator==(const UIDataSettingsGlobalNetworkNAT &other) const { return equal(other); }
+    /** Returns whether the @a other passed data is different from this one. */
+    bool operator!=(const UIDataSettingsGlobalNetworkNAT &other) const { return !equal(other); }
 
     /** Holds whether this network enabled. */
@@ -69,9 +87,20 @@
 
 
-/** Global settings: Network page: Host interface cache structure. */
+/** Global settings: Network page: Host interface data structure. */
 struct UIDataSettingsGlobalNetworkHostInterface
 {
-    /** Returns whether the @a other passed data is equal to this one. */
-    bool operator==(const UIDataSettingsGlobalNetworkHostInterface &other) const
+    /** Constructs data. */
+    UIDataSettingsGlobalNetworkHostInterface()
+        : m_strName(QString())
+        , m_fDhcpClientEnabled(false)
+        , m_strInterfaceAddress(QString())
+        , m_strInterfaceMask(QString())
+        , m_fIpv6Supported(false)
+        , m_strInterfaceAddress6(QString())
+        , m_strInterfaceMaskLength6(QString())
+    {}
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool equal(const UIDataSettingsGlobalNetworkHostInterface &other) const
     {
         return true
@@ -85,4 +114,9 @@
                ;
     }
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool operator==(const UIDataSettingsGlobalNetworkHostInterface &other) const { return equal(other); }
+    /** Returns whether the @a other passed data is different from this one. */
+    bool operator!=(const UIDataSettingsGlobalNetworkHostInterface &other) const { return !equal(other); }
 
     /** Holds host interface name. */
@@ -103,9 +137,18 @@
 
 
-/** Global settings: Network page: DHCP server cache structure. */
+/** Global settings: Network page: DHCP server data structure. */
 struct UIDataSettingsGlobalNetworkDHCPServer
 {
-    /** Returns whether the @a other passed data is equal to this one. */
-    bool operator==(const UIDataSettingsGlobalNetworkDHCPServer &other) const
+    /** Constructs data. */
+    UIDataSettingsGlobalNetworkDHCPServer()
+        : m_fDhcpServerEnabled(false)
+        , m_strDhcpServerAddress(QString())
+        , m_strDhcpServerMask(QString())
+        , m_strDhcpLowerAddress(QString())
+        , m_strDhcpUpperAddress(QString())
+    {}
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool equal(const UIDataSettingsGlobalNetworkDHCPServer &other) const
     {
         return true
@@ -117,4 +160,9 @@
                ;
     }
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool operator==(const UIDataSettingsGlobalNetworkDHCPServer &other) const { return equal(other); }
+    /** Returns whether the @a other passed data is different from this one. */
+    bool operator!=(const UIDataSettingsGlobalNetworkDHCPServer &other) const { return !equal(other); }
 
     /** Holds whether DHCP server enabled. */
@@ -131,9 +179,15 @@
 
 
-/** Global settings: Network page: Host network cache structure. */
+/** Global settings: Network page: Host network data structure. */
 struct UIDataSettingsGlobalNetworkHost
 {
-    /** Returns whether the @a other passed data is equal to this one. */
-    bool operator==(const UIDataSettingsGlobalNetworkHost &other) const
+    /** Constructs data. */
+    UIDataSettingsGlobalNetworkHost()
+        : m_interface(UIDataSettingsGlobalNetworkHostInterface())
+        , m_dhcpserver(UIDataSettingsGlobalNetworkDHCPServer())
+    {}
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool equal(const UIDataSettingsGlobalNetworkHost &other) const
     {
         return true
@@ -142,4 +196,9 @@
                ;
     }
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool operator==(const UIDataSettingsGlobalNetworkHost &other) const { return equal(other); }
+    /** Returns whether the @a other passed data is different from this one. */
+    bool operator!=(const UIDataSettingsGlobalNetworkHost &other) const { return !equal(other); }
 
     /** Holds the host interface data. */
@@ -150,7 +209,27 @@
 
 
-/** Global settings: Network page cache structure. */
-struct UISettingsCacheGlobalNetwork
-{
+/** Global settings: Network page data structure. */
+struct UIDataSettingsGlobalNetwork
+{
+    /** Constructs data. */
+    UIDataSettingsGlobalNetwork()
+        : m_networksNAT(QList<UIDataSettingsGlobalNetworkNAT>())
+        , m_networksHost(QList<UIDataSettingsGlobalNetworkHost>())
+    {}
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool equal(const UIDataSettingsGlobalNetwork &other) const
+    {
+        return true
+               && (m_networksNAT == other.m_networksNAT)
+               && (m_networksHost == other.m_networksHost)
+               ;
+    }
+
+    /** Returns whether the @a other passed data is equal to this one. */
+    bool operator==(const UIDataSettingsGlobalNetwork &other) const { return equal(other); }
+    /** Returns whether the @a other passed data is different from this one. */
+    bool operator!=(const UIDataSettingsGlobalNetwork &other) const { return !equal(other); }
+
     /** Holds the NAT network data. */
     QList<UIDataSettingsGlobalNetworkNAT> m_networksNAT;
@@ -158,4 +237,5 @@
     QList<UIDataSettingsGlobalNetworkHost> m_networksHost;
 };
+typedef UISettingsCache<UIDataSettingsGlobalNetwork> UISettingsCacheGlobalNetwork;
 
 
@@ -244,7 +324,4 @@
     QAction *m_pActionEditNetworkHost;
 
-    /* Variable: Editness flag: */
-    bool m_fChanged;
-
     /* Variable: Cache: */
     UISettingsCacheGlobalNetwork m_cache;
