- Timestamp:
- Apr 3, 2013 5:12:10 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r45308 r45313 412 412 } 413 413 414 void UIMessageCenter::cannotOpenSession(const CMachine &machine, const CProgress &progress /* = CProgress() */) const 415 { 416 /* Format error-info: */ 417 Assert(!machine.isOk() || !progress.isNull()); 418 QString strErrorInfo = !machine.isOk() ? formatErrorInfo(machine) : 419 !progress.isOk() ? formatErrorInfo(progress) : 420 formatErrorInfo(progress.GetErrorInfo()); 421 /* Compose machine name: */ 422 QString strName = machine.GetName(); 423 if (strName.isEmpty()) 424 strName = QFileInfo(machine.GetSettingsFilePath()).baseName(); 414 void UIMessageCenter::cannotOpenSession(const CMachine &machine) const 415 { 416 /* Preserve error-info: */ 417 QString strErrorInfo = formatErrorInfo(machine); 425 418 /* Show the message: */ 426 419 message(mainWindowShown(), MessageType_Error, 427 420 tr("Failed to open a session for the virtual machine <b>%1</b>.") 428 .arg( strName),421 .arg(machine.GetName()), 429 422 strErrorInfo); 423 } 424 425 void UIMessageCenter::cannotOpenSession(const CProgress &progress, const QString &strMachineName) const 426 { 427 message(mainWindowShown(), MessageType_Error, 428 tr("Failed to open a session for the virtual machine <b>%1</b>.") 429 .arg(strMachineName), 430 !progress.isOk() ? formatErrorInfo(progress) : formatErrorInfo(progress.GetErrorInfo())); 430 431 } 431 432 … … 603 604 tr("Failed to remove the virtual machine <b>%1</b>.") 604 605 .arg(machine.GetName()), 605 formatErrorInfo(progress.GetErrorInfo()));606 !progress.isOk() ? formatErrorInfo(progress) : formatErrorInfo(progress.GetErrorInfo())); 606 607 } 607 608 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r45296 r45313 208 208 void cannotFindMachineById(const CVirtualBox &vbox, const QString &strId) const; 209 209 void cannotOpenSession(const CSession &session) const; 210 void cannotOpenSession(const CMachine &machine, const CProgress &progress = CProgress()) const; 210 void cannotOpenSession(const CMachine &machine) const; 211 void cannotOpenSession(const CProgress &progress, const QString &strMachineName) const; 211 212 void cannotGetMediaAccessibility(const UIMedium &medium) const; 212 213 void cannotOpenURL(const QString &strUrl) const; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r45292 r45313 1727 1727 CSession VBoxGlobal::openSession(const QString &strId, KLockType lockType /* = KLockType_Shared */) 1728 1728 { 1729 /* Create empty session instance: */1729 /* Prepare session: */ 1730 1730 CSession session; 1731 session.createInstance(CLSID_Session); 1732 if (session.isNull()) 1733 { 1734 msgCenter().cannotOpenSession(session); 1735 return session; 1736 } 1737 1738 /* Search for the corresponding machine: */ 1739 CMachine machine = mVBox.FindMachine(strId); 1740 if (machine.isNull()) 1741 { 1742 msgCenter().cannotFindMachineById(mVBox, strId); 1743 return session; 1744 } 1745 1746 /* Lock found machine to session: */ 1747 machine.LockMachine(session, lockType); 1748 if (!machine.isOk()) 1749 { 1750 msgCenter().cannotOpenSession(machine); 1731 1732 /* Simulate try-catch block: */ 1733 bool fSuccess = false; 1734 do 1735 { 1736 /* Create empty session instance: */ 1737 session.createInstance(CLSID_Session); 1738 if (session.isNull()) 1739 { 1740 msgCenter().cannotOpenSession(session); 1741 break; 1742 } 1743 1744 /* Search for the corresponding machine: */ 1745 CMachine machine = mVBox.FindMachine(strId); 1746 if (machine.isNull()) 1747 { 1748 msgCenter().cannotFindMachineById(mVBox, strId); 1749 break; 1750 } 1751 1752 /* Lock found machine to session: */ 1753 machine.LockMachine(session, lockType); 1754 if (!machine.isOk()) 1755 { 1756 msgCenter().cannotOpenSession(machine); 1757 break; 1758 } 1759 1760 /* Pass the language ID as the property to the guest: */ 1761 if (session.GetType() == KSessionType_Shared) 1762 { 1763 CMachine startedMachine = session.GetMachine(); 1764 /* Make sure that the language is in two letter code. 1765 * Note: if languageId() returns an empty string lang.name() will 1766 * return "C" which is an valid language code. */ 1767 QLocale lang(VBoxGlobal::languageId()); 1768 startedMachine.SetGuestPropertyValue("/VirtualBox/HostInfo/GUI/LanguageID", lang.name()); 1769 } 1770 1771 /* Success finally: */ 1772 fSuccess = true; 1773 } 1774 while (0); 1775 /* Cleanup try-catch block: */ 1776 if (!fSuccess) 1751 1777 session.detach(); 1752 return session; 1753 } 1754 1755 /* Pass the language ID as the property to the guest: */ 1756 if (session.GetType() == KSessionType_Shared) 1757 { 1758 CMachine startedMachine = session.GetMachine(); 1759 /* Make sure that the language is in two letter code. 1760 * Note: if languageId() returns an empty string lang.name() will 1761 * return "C" which is an valid language code. */ 1762 QLocale lang(VBoxGlobal::languageId()); 1763 startedMachine.SetGuestPropertyValue("/VirtualBox/HostInfo/GUI/LanguageID", lang.name()); 1764 } 1765 1766 /* Return resulting session: */ 1778 1779 /* Return session: */ 1767 1780 return session; 1768 1781 } … … 4960 4973 int iSpawningDuration = 60000; 4961 4974 msgCenter().showModalProgressDialog(progress, machine.GetName(), "", mainWindow(), iSpawningDuration); 4962 if ( progress.GetResultCode() != 0)4963 msgCenter().cannotOpenSession( machine, progress);4975 if (!progress.isOk() || progress.GetResultCode() != 0) 4976 msgCenter().cannotOpenSession(progress, machine.GetName()); 4964 4977 4965 4978 /* Unlock machine, close session: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r45296 r45313 1484 1484 /* And show cleanup progress finally: */ 1485 1485 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_delete_90px.png"); 1486 if ( progress.GetResultCode() != 0)1486 if (!progress.isOk() || progress.GetResultCode() != 0) 1487 1487 { 1488 1488 msgCenter().cannotRemoveMachine(machine, progress);
Note:
See TracChangeset
for help on using the changeset viewer.