VirtualBox

Changeset 7351 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 7, 2008 11:35:29 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28771
Message:

FE/Qt: Use IVirtualBox/IMachine::saveSettingsWithBackup() for creating backup copies of the settings files when auto-converting.

Location:
trunk/src/VBox/Frontends
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r7342 r7351  
    18721872            .warnAboutAutoConvertedSettings (formatVersion, fileList);
    18731873
    1874         if (rc == QIMessageBox::No)
    1875         {
    1876             /* create backup copies */
    1877             for (QValueList <CMachine>::Iterator m = machines.begin();
    1878                  /* machines.end() means global config => manual loop break */ ;)
    1879             {
    1880                 QString of, nf;
    1881 
    1882                 if (m == machines.end())
    1883                 {
    1884                     if (!isGlobalConverted)
    1885                         break;
    1886                     of = mVBox.GetSettingsFilePath();
    1887                     nf = QString ("%1.%2.bak").arg (of, mVBox.GetSettingsFileVersion());
    1888                 }
    1889                 else
    1890                 {
    1891                     of = (*m).GetSettingsFilePath();
    1892                     nf = QString ("%1.%2.bak").arg (of, (*m).GetSettingsFileVersion());
    1893                 }
    1894 
    1895                 int vrc = RTFileCopyEx (of.utf8(), nf.utf8(),
    1896                                         RTFILECOPY_FLAG_NO_DENY_WRITE,
    1897                                         NULL, NULL);
    1898 
    1899                 /* try progressive suffix on failure */
    1900                 if (vrc == VERR_ALREADY_EXISTS)
    1901                 {
    1902                     QString tmp = nf;
    1903                     for (int i = 0; i < 9 && RT_FAILURE (vrc); ++ i)
    1904                     {
    1905                         nf = QString ("%1.%2"). arg (tmp).arg (i);
    1906                         vrc = RTFileCopyEx (of.utf8(), nf.utf8(),
    1907                                             RTFILECOPY_FLAG_NO_DENY_WRITE,
    1908                                             NULL, NULL);
    1909                     }
    1910                 }
    1911 
    1912                 if (RT_FAILURE (vrc))
    1913                 {
    1914                     vboxProblem().cannotCopyFile (of, nf, vrc);
    1915                     if (m == machines.end())
    1916                     {
    1917                         /* remove from further processing */
    1918                         isGlobalConverted = false;
    1919                         break;
    1920                     }
    1921                     else
    1922                         /* remove from further processing */
    1923                         m = machines.remove (m);
    1924                 }
    1925                 else
    1926                 {
    1927                     if (m == machines.end())
    1928                         break;
    1929                     ++ m;
    1930                 }
    1931             }
    1932         }
    1933 
    1934         if (rc == QIMessageBox::Yes || rc == QIMessageBox::No)
    1935         {
    1936             /* save all settings files */
     1874        if (rc == QIMessageBox::No || rc == QIMessageBox::Yes)
     1875        {
     1876            /* backup (optionally) and save all settings files
     1877             * (QIMessageBox::No = Backup, QIMessageBox::Yes = Save) */
     1878
    19371879            for (QValueList <CMachine>::Iterator m = machines.begin();
    19381880                 /* machines.end() means global config => manual loop break */ ;)
     
    19421884                    if (isGlobalConverted)
    19431885                    {
    1944                         mVBox.SaveSettings();
     1886                        if (rc == QIMessageBox::No)
     1887                            mVBox.SaveSettingsWithBackup();
     1888                        else
     1889                            mVBox.SaveSettings();
     1890
    19451891                        if (!mVBox.isOk())
    19461892                            vboxProblem().cannotSaveGlobalSettings (mVBox);
     
    19531899                    {
    19541900                        CMachine sm = session.GetMachine();
    1955                         sm.SaveSettings();
     1901                        if (rc == QIMessageBox::No)
     1902                            sm.SaveSettingsWithBackup();
     1903                        else
     1904                            sm.SaveSettings();
     1905                        ;
    19561906                        if (!sm.isOk())
    19571907                            vboxProblem().cannotSaveMachineSettings (sm);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r7342 r7351  
    16621662            "<p>Note that if you select <b>Cancel</b>, the auto-converted "
    16631663            "settings files will be implicitly saved in the new format anyway "
    1664             "once you change a setting or start a virtual machine.</p>")
     1664            "once you change a setting or start a virtual machine, but "
     1665            "<b>no</b> backup copies will be created in this case.</p>")
    16651666            .arg (aFormatVersion),
    16661667        aFileList,
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp

    r7342 r7351  
    18861886            .warnAboutAutoConvertedSettings (formatVersion, fileList);
    18871887
    1888         if (rc == QIMessageBox::No)
    1889         {
    1890             /* create backup copies */
    1891             for (QList <CMachine>::Iterator m = machines.begin();
    1892                  /* machines.end() means global config => manual loop break */ ;)
    1893             {
    1894                 QString of, nf;
    1895 
    1896                 if (m == machines.end())
    1897                 {
    1898                     if (!isGlobalConverted)
    1899                         break;
    1900                     of = mVBox.GetSettingsFilePath();
    1901                     nf = QString ("%1.%2.bak").arg (of, mVBox.GetSettingsFileVersion());
    1902                 }
    1903                 else
    1904                 {
    1905                     of = (*m).GetSettingsFilePath();
    1906                     nf = QString ("%1.%2.bak").arg (of, (*m).GetSettingsFileVersion());
    1907                 }
    1908 
    1909                 int vrc = RTFileCopyEx (of.utf8(), nf.utf8(),
    1910                                         RTFILECOPY_FLAG_NO_DENY_WRITE,
    1911                                         NULL, NULL);
    1912 
    1913                 /* try progressive suffix on failure */
    1914                 if (vrc == VERR_ALREADY_EXISTS)
    1915                 {
    1916                     QString tmp = nf;
    1917                     for (int i = 0; i < 9 && RT_FAILURE (vrc); ++ i)
    1918                     {
    1919                         nf = QString ("%1.%2"). arg (tmp).arg (i);
    1920                         vrc = RTFileCopyEx (of.utf8(), nf.utf8(),
    1921                                             RTFILECOPY_FLAG_NO_DENY_WRITE,
    1922                                             NULL, NULL);
    1923                     }
    1924                 }
    1925 
    1926                 if (RT_FAILURE (vrc))
    1927                 {
    1928                     vboxProblem().cannotCopyFile (of, nf, vrc);
    1929                     if (m == machines.end())
    1930                     {
    1931                         /* remove from further processing */
    1932                         isGlobalConverted = false;
    1933                         break;
    1934                     }
    1935                     else
    1936                         /* remove from further processing */
    1937                         m = machines.remove (m);
    1938                 }
    1939                 else
    1940                 {
    1941                     if (m == machines.end())
    1942                         break;
    1943                     ++ m;
    1944                 }
    1945             }
    1946         }
    1947 
    1948         if (rc == QIMessageBox::Yes || rc == QIMessageBox::No)
    1949         {
    1950             /* save all settings files */
     1888        if (rc == QIMessageBox::No || rc == QIMessageBox::Yes)
     1889        {
     1890            /* backup (optionally) and save all settings files
     1891             * (QIMessageBox::No = Backup, QIMessageBox::Yes = Save) */
     1892
    19511893            for (QList <CMachine>::Iterator m = machines.begin();
    19521894                 /* machines.end() means global config => manual loop break */ ;)
     
    19561898                    if (isGlobalConverted)
    19571899                    {
    1958                         mVBox.SaveSettings();
     1900                        if (rc == QIMessageBox::No)
     1901                            mVBox.SaveSettingsWithBackup();
     1902                        else
     1903                            mVBox.SaveSettings();
     1904
    19591905                        if (!mVBox.isOk())
    19601906                            vboxProblem().cannotSaveGlobalSettings (mVBox);
     
    19671913                    {
    19681914                        CMachine sm = session.GetMachine();
    1969                         sm.SaveSettings();
     1915                        if (rc == QIMessageBox::No)
     1916                            sm.SaveSettingsWithBackup();
     1917                        else
     1918                            sm.SaveSettings();
     1919                        ;
    19701920                        if (!sm.isOk())
    19711921                            vboxProblem().cannotSaveMachineSettings (sm);
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxProblemReporter.cpp

    r7342 r7351  
    16681668            "<p>Note that if you select <b>Cancel</b>, the auto-converted "
    16691669            "settings files will be implicitly saved in the new format anyway "
    1670             "once you change a setting or start a virtual machine.</p>")
     1670            "once you change a setting or start a virtual machine, but "
     1671            "<b>no</b> backup copies will be created in this case.</p>")
    16711672            .arg (aFormatVersion),
    16721673        aFileList,
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette