Index: trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp	(revision 36929)
+++ trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp	(revision 36930)
@@ -61,26 +61,32 @@
 void UIMachineSettingsParallel::polishTab()
 {
+    /* Polish port page: */
+    ulong uIRQ, uIOBase;
+    bool fStd = vboxGlobal().toCOMPortNumbers(mCbNumber->currentText(), uIRQ, uIOBase);
     mGbParallel->setEnabled(m_pParent->isMachineOffline());
     mLbNumber->setEnabled(m_pParent->isMachineOffline());
     mCbNumber->setEnabled(m_pParent->isMachineOffline());
     mLbIRQ->setEnabled(m_pParent->isMachineOffline());
-    mLeIRQ->setEnabled(m_pParent->isMachineOffline());
+    mLeIRQ->setEnabled(!fStd && m_pParent->isMachineOffline());
     mLbIOPort->setEnabled(m_pParent->isMachineOffline());
-    mLeIOPort->setEnabled(m_pParent->isMachineOffline());
+    mLeIOPort->setEnabled(!fStd && m_pParent->isMachineOffline());
     mLbPath->setEnabled(m_pParent->isMachineOffline());
     mLePath->setEnabled(m_pParent->isMachineOffline());
 }
 
-void UIMachineSettingsParallel::fetchPortData(const UIParallelPortData &data)
-{
-    /* Load port slot number: */
-    m_iSlot = data.m_iSlot;
-
-    /* Fetch port data: */
-    mGbParallel->setChecked(data.m_fPortEnabled);
-    mCbNumber->setCurrentIndex(mCbNumber->findText(vboxGlobal().toCOMPortName(data.m_uIRQ, data.m_uIOBase)));
-    mLeIRQ->setText(QString::number(data.m_uIRQ));
-    mLeIOPort->setText("0x" + QString::number(data.m_uIOBase, 16).toUpper());
-    mLePath->setText(data.m_strPath);
+void UIMachineSettingsParallel::fetchPortData(const UICacheSettingsMachineParallelPort &portCache)
+{
+    /* Get port data: */
+    const UIDataSettingsMachineParallelPort &portData = portCache.base();
+
+    /* Load port number: */
+    m_iSlot = portData.m_iSlot;
+
+    /* Load port data: */
+    mGbParallel->setChecked(portData.m_fPortEnabled);
+    mCbNumber->setCurrentIndex(mCbNumber->findText(vboxGlobal().toCOMPortName(portData.m_uIRQ, portData.m_uIOBase)));
+    mLeIRQ->setText(QString::number(portData.m_uIRQ));
+    mLeIOPort->setText("0x" + QString::number(portData.m_uIOBase, 16).toUpper());
+    mLePath->setText(portData.m_strPath);
 
     /* Ensure everything is up-to-date */
@@ -88,11 +94,17 @@
 }
 
-void UIMachineSettingsParallel::uploadPortData(UIParallelPortData &data)
-{
-    /* Upload port data: */
-    data.m_fPortEnabled = mGbParallel->isChecked();
-    data.m_uIRQ = mLeIRQ->text().toULong(NULL, 0);
-    data.m_uIOBase = mLeIOPort->text().toULong(NULL, 0);
-    data.m_strPath = QDir::toNativeSeparators(mLePath->text());
+void UIMachineSettingsParallel::uploadPortData(UICacheSettingsMachineParallelPort &portCache)
+{
+    /* Prepare port data: */
+    UIDataSettingsMachineParallelPort portData = portCache.base();
+
+    /* Save port data: */
+    portData.m_fPortEnabled = mGbParallel->isChecked();
+    portData.m_uIRQ = mLeIRQ->text().toULong(NULL, 0);
+    portData.m_uIOBase = mLeIOPort->text().toULong(NULL, 0);
+    portData.m_strPath = QDir::toNativeSeparators(mLePath->text());
+
+    /* Cache port data: */
+    portCache.cacheCurrentData(portData);
 }
 
@@ -172,4 +184,14 @@
     layout->setContentsMargins (0, 5, 0, 5);
     layout->addWidget (mTabWidget);
+
+    /* How many ports to display: */
+    ulong uCount = vboxGlobal().virtualBox().GetSystemProperties().GetParallelPortCount();
+    /* Add corresponding tab pages to parent tab widget: */
+    for (ulong uPort = 0; uPort < uCount; ++uPort)
+    {
+        /* Creating port page: */
+        UIMachineSettingsParallel *pPage = new UIMachineSettingsParallel(this);
+        mTabWidget->addTab(pPage, pPage->pageTitle());
+    }
 }
 
@@ -181,23 +203,24 @@
     UISettingsPageMachine::fetchData(data);
 
-    /* Load port data: */
-    ulong uCount = vboxGlobal().virtualBox().GetSystemProperties().GetParallelPortCount();
-    for (ulong uSlot = 0; uSlot < uCount; ++uSlot)
-    {
-        /* Get port: */
-        const CParallelPort &port = m_machine.GetParallelPort(uSlot);
-
-        /* Prepare port's data container: */
-        UIParallelPortData data;
-
-        /* Load options: */
-        data.m_iSlot = uSlot;
-        data.m_fPortEnabled = port.GetEnabled();
-        data.m_uIRQ = port.GetIRQ();
-        data.m_uIOBase = port.GetIOBase();
-        data.m_strPath = port.GetPath();
-
-        /* Append adapter's data container: */
-        m_cache.m_items << data;
+    /* For each parallel port: */
+    for (int iSlot = 0; iSlot < mTabWidget->count(); ++iSlot)
+    {
+        /* Prepare port data: */
+        UIDataSettingsMachineParallelPort portData;
+
+        /* Check if port is valid: */
+        const CParallelPort &port = m_machine.GetParallelPort(iSlot);
+        if (!port.isNull())
+        {
+            /* Gather options: */
+            portData.m_iSlot = iSlot;
+            portData.m_fPortEnabled = port.GetEnabled();
+            portData.m_uIRQ = port.GetIRQ();
+            portData.m_uIOBase = port.GetIOBase();
+            portData.m_strPath = port.GetPath();
+        }
+
+        /* Cache port data: */
+        m_cache.child(iSlot).cacheInitialData(portData);
     }
 
@@ -210,19 +233,17 @@
 void UIMachineSettingsParallelPage::getFromCache()
 {
+    /* Setup tab order: */
     Assert(firstWidget());
     setTabOrder(firstWidget(), mTabWidget->focusProxy());
     QWidget *pLastFocusWidget = mTabWidget->focusProxy();
 
-    /* Apply internal variables data to QWidget(s): */
-    for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot)
-    {
-        /* Creating port's page: */
-        UIMachineSettingsParallel *pPage = new UIMachineSettingsParallel(this);
-
-        /* Loading port's data into page: */
-        pPage->fetchPortData(m_cache.m_items[iSlot]);
-
-        /* Attach port's page to Tab Widget: */
-        mTabWidget->addTab(pPage, pPage->pageTitle());
+    /* For each parallel port: */
+    for (int iPort = 0; iPort < mTabWidget->count(); ++iPort)
+    {
+        /* Get port page: */
+        UIMachineSettingsParallel *pPage = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iPort));
+
+        /* Load port data to page: */
+        pPage->fetchPortData(m_cache.child(iPort));
 
         /* Setup page validation: */
@@ -244,12 +265,12 @@
 void UIMachineSettingsParallelPage::putToCache()
 {
-    /* Gather internal variables data from QWidget(s): */
-    for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot)
-    {
-        /* Getting adapter's page: */
-        UIMachineSettingsParallel *pPage = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iSlot));
-
-        /* Loading Adapter's data from page: */
-        pPage->uploadPortData(m_cache.m_items[iSlot]);
+    /* For each parallel port: */
+    for (int iPort = 0; iPort < mTabWidget->count(); ++iPort)
+    {
+        /* Getting port page: */
+        UIMachineSettingsParallel *pPage = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iPort));
+
+        /* Gather & cache port data: */
+        pPage->uploadPortData(m_cache.child(iPort));
     }
 }
@@ -262,20 +283,31 @@
     UISettingsPageMachine::fetchData(data);
 
-    if (isMachineOffline())
-    {
-        /* Gather corresponding values from internal variables: */
-        for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot)
+    /* Check if ports data was changed: */
+    if (m_cache.wasChanged())
+    {
+        /* For each parallel port: */
+        for (int iPort = 0; iPort < mTabWidget->count(); ++iPort)
         {
-            /* Get adapter: */
-            CParallelPort port = m_machine.GetParallelPort(iSlot);
-
-            /* Get cached data for this slot: */
-            const UIParallelPortData &data = m_cache.m_items[iSlot];
-
-            /* Save options: */
-            port.SetIRQ(data.m_uIRQ);
-            port.SetIOBase(data.m_uIOBase);
-            port.SetPath(data.m_strPath);
-            port.SetEnabled(data.m_fPortEnabled);
+            /* Check if port data was changed: */
+            const UICacheSettingsMachineParallelPort &portCache = m_cache.child(iPort);
+            if (portCache.wasChanged())
+            {
+                /* Check if port still valid: */
+                CParallelPort port = m_machine.GetParallelPort(iPort);
+                if (!port.isNull())
+                {
+                    /* Get port data from cache: */
+                    const UIDataSettingsMachineParallelPort &portData = portCache.data();
+
+                    /* Store adapter data: */
+                    if (isMachineOffline())
+                    {
+                        port.SetIRQ(portData.m_uIRQ);
+                        port.SetIOBase(portData.m_uIOBase);
+                        port.SetPath(portData.m_strPath);
+                        port.SetEnabled(portData.m_fPortEnabled);
+                    }
+                }
+            }
         }
     }
@@ -352,11 +384,10 @@
 {
     /* Get the count of parallel port tabs: */
-    for (int iTabIndex = 0; iTabIndex < mTabWidget->count(); ++iTabIndex)
-    {
-        mTabWidget->setTabEnabled(iTabIndex,
+    for (int iPort = 0; iPort < mTabWidget->count(); ++iPort)
+    {
+        mTabWidget->setTabEnabled(iPort,
                                   isMachineOffline() ||
-                                  (isMachineInValidMode() && m_cache.m_items[iTabIndex].m_fPortEnabled));
-        UIMachineSettingsParallel *pTab = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iTabIndex));
-        Assert(pTab);
+                                  (isMachineInValidMode() && m_cache.child(iPort).base().m_fPortEnabled));
+        UIMachineSettingsParallel *pTab = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iPort));
         pTab->polishTab();
     }
Index: trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h	(revision 36929)
+++ trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h	(revision 36930)
@@ -28,6 +28,27 @@
 class QITabWidget;
 
-struct UIParallelPortData
+/* Machine settings / Parallel page / Port data: */
+struct UIDataSettingsMachineParallelPort
 {
+    /* Default constructor: */
+    UIDataSettingsMachineParallelPort()
+        : m_iSlot(-1)
+        , m_fPortEnabled(false)
+        , m_uIRQ(0)
+        , m_uIOBase(0)
+        , m_strPath(QString()) {}
+    /* Functions: */
+    bool equal(const UIDataSettingsMachineParallelPort &other) const
+    {
+        return (m_iSlot == other.m_iSlot) &&
+               (m_fPortEnabled == other.m_fPortEnabled) &&
+               (m_uIRQ == other.m_uIRQ) &&
+               (m_uIOBase == other.m_uIOBase) &&
+               (m_strPath == other.m_strPath);
+    }
+    /* Operators: */
+    bool operator==(const UIDataSettingsMachineParallelPort &other) const { return equal(other); }
+    bool operator!=(const UIDataSettingsMachineParallelPort &other) const { return !equal(other); }
+    /* Variables: */
     int m_iSlot;
     bool m_fPortEnabled;
@@ -36,10 +57,16 @@
     QString m_strPath;
 };
+typedef UISettingsCache<UIDataSettingsMachineParallelPort> UICacheSettingsMachineParallelPort;
 
-/* Machine settings / Parallel page / Cache: */
-struct UISettingsCacheMachineParallel
+/* Machine settings / Parallel page / Ports data: */
+struct UIDataSettingsMachineParallel
 {
-    QList<UIParallelPortData> m_items;
+    /* Default constructor: */
+    UIDataSettingsMachineParallel() {}
+    /* Operators: */
+    bool operator==(const UIDataSettingsMachineParallel& /* other */) const { return true; }
+    bool operator!=(const UIDataSettingsMachineParallel& /* other */) const { return false; }
 };
+typedef UISettingsCachePool<UIDataSettingsMachineParallel, UICacheSettingsMachineParallelPort> UICacheSettingsMachineParallel;
 
 class UIMachineSettingsParallel : public QIWithRetranslateUI<QWidget>,
@@ -54,6 +81,6 @@
     void polishTab();
 
-    void fetchPortData(const UIParallelPortData &data);
-    void uploadPortData(UIParallelPortData &data);
+    void fetchPortData(const UICacheSettingsMachineParallelPort &portCache);
+    void uploadPortData(UICacheSettingsMachineParallelPort &portCache);
 
     void setValidator (QIWidgetValidator *aVal);
@@ -117,6 +144,6 @@
     QITabWidget *mTabWidget;
 
-    /* Internals: */
-    UISettingsCacheMachineParallel m_cache;
+    /* Cache: */
+    UICacheSettingsMachineParallel m_cache;
 };
 
