- Timestamp:
- Apr 2, 2013 6:04:05 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r45274 r45275 409 409 } 410 410 411 void UIMessageCenter::cannotOpenSession(const C VirtualBox &vbox, const CMachine &machine,411 void UIMessageCenter::cannotOpenSession(const CMachine &machine, 412 412 const CProgress &progress /* = CProgress() */) 413 413 { 414 Assert(!vbox.isOk() || progress.isOk()); 414 /* Format error-info: */ 415 Assert(!machine.isOk() || !progress.isNull()); 416 QString strErrorInfo = !machine.isOk() ? formatErrorInfo(machine) : 417 !progress.isOk() ? formatErrorInfo(progress) : 418 formatErrorInfo(progress.GetErrorInfo()); 415 419 /* Compose machine name: */ 416 420 QString strName = machine.GetName(); … … 420 424 message(mainWindowShown(), MessageType_Error, 421 425 tr("Failed to open a session for the virtual machine <b>%1</b>.").arg(strName), 422 !vbox.isOk() ? formatErrorInfo(vbox) : formatErrorInfo(progress.GetErrorInfo())); 423 } 424 425 void UIMessageCenter::cannotOpenSession(const CMachine &machine) 426 { 427 /* Preserve error-info: */ 428 COMResult res(machine); 429 /* Compose machine name: */ 430 QString strName = machine.GetName(); 431 if (strName.isEmpty()) 432 strName = QFileInfo(machine.GetSettingsFilePath()).baseName(); 433 /* Show the message: */ 434 message(mainWindowShown(), MessageType_Error, 435 tr("Failed to open a session for the virtual machine <b>%1</b>.").arg(strName), 436 formatErrorInfo(res)); 426 strErrorInfo); 437 427 } 438 428 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r45271 r45275 205 205 void cannotFindMachineById(const CVirtualBox &vbox, const QString &strId); 206 206 void cannotOpenSession(const CSession &session); 207 void cannotOpenSession(const CVirtualBox &vbox, const CMachine &machine, const CProgress &progress = CProgress()); 208 void cannotOpenSession(const CMachine &machine); 207 void cannotOpenSession(const CMachine &machine, const CProgress &progress = CProgress()); 209 208 void cannotGetMediaAccessibility(const UIMedium &medium); 210 209 void cannotOpenURL(const QString &strUrl); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r45272 r45275 1749 1749 { 1750 1750 msgCenter().cannotOpenSession(machine); 1751 session.detach();1752 return session;1753 }1754 else if (!mVBox.isOk())1755 {1756 msgCenter().cannotOpenSession(mVBox, machine);1757 1751 session.detach(); 1758 1752 return session; … … 4915 4909 bool VBoxGlobal::launchMachine(CMachine &machine, bool fHeadless /* = false */) 4916 4910 { 4911 /* Switch to machine window(s) if possible: */ 4917 4912 if (machine.CanShowConsoleWindow()) 4918 4913 return VBoxGlobal::switchToMachine(machine); 4919 4914 4915 /* Make sure machine-state is one of required: */ 4920 4916 KMachineState state = machine.GetState(); NOREF(state); 4921 4917 AssertMsg( state == KMachineState_PoweredOff … … 4923 4919 || state == KMachineState_Teleported 4924 4920 || state == KMachineState_Aborted 4925 , ("Machine must be PoweredOff/Saved/ Aborted (%d)", state));4926 4927 CVirtualBox vbox = vboxGlobal().virtualBox();4921 , ("Machine must be PoweredOff/Saved/Teleported/Aborted (%d)", state)); 4922 4923 /* Create empty session instance: */ 4928 4924 CSession session; 4929 4925 session.createInstance(CLSID_Session); … … 4934 4930 } 4935 4931 4936 #if defined(Q_OS_WIN32) 4937 /* allow the started VM process to make itself the foreground window */ 4932 /* Configure environment: */ 4933 QString strEnv; 4934 #ifdef Q_OS_WIN 4935 /* Allow started VM process to be foreground window: */ 4938 4936 AllowSetForegroundWindow(ASFW_ANY); 4939 #endif 4940 4941 QString env; 4942 #if defined(Q_WS_X11) 4943 /* make sure the VM process will start on the same display as the Selector */ 4944 const char *display = RTEnvGet("DISPLAY"); 4945 if (display) 4946 env.append(QString("DISPLAY=%1\n").arg(display)); 4947 const char *xauth = RTEnvGet("XAUTHORITY"); 4948 if (xauth) 4949 env.append(QString("XAUTHORITY=%1\n").arg(xauth)); 4950 #endif 4937 #endif /* Q_OS_WIN */ 4938 #ifdef Q_WS_X11 4939 /* Make sure VM process will start on the same display as the VM selector: */ 4940 const char *pDisplay = RTEnvGet("DISPLAY"); 4941 if (pDisplay) 4942 strEnv.append(QString("DISPLAY=%1\n").arg(pDisplay)); 4943 const char *pXauth = RTEnvGet("XAUTHORITY"); 4944 if (pXauth) 4945 strEnv.append(QString("XAUTHORITY=%1\n").arg(pXauth)); 4946 #endif /* Q_WS_X11 */ 4951 4947 const QString strType = fHeadless ? "headless" : ""; 4952 4948 4953 CProgress progress = machine.LaunchVMProcess(session, strType, env);4954 if ( !vbox.isOk()4955 || progress.isNull())4956 { 4957 msgCenter().cannotOpenSession( vbox,machine);4949 /* Prepare "VM spawning" progress: */ 4950 CProgress progress = machine.LaunchVMProcess(session, strType, strEnv); 4951 if (!machine.isOk()) 4952 { 4953 msgCenter().cannotOpenSession(machine); 4958 4954 return false; 4959 4955 } 4960 4956 4961 /* Hide the "VM spawning" progress dialog */ 4962 /* I hope 1 minute will be enough to spawn any running VM silently, isn't it? */ 4957 /* Postpone showing "VM spawning" progress. 4958 * Hope 1 minute will be enough to spawn any running VM silently, 4959 * otherwise we better show the progress... */ 4963 4960 int iSpawningDuration = 60000; 4964 4961 msgCenter().showModalProgressDialog(progress, machine.GetName(), "", mainWindow(), iSpawningDuration); 4965 4962 if (progress.GetResultCode() != 0) 4966 msgCenter().cannotOpenSession(vbox, machine, progress); 4967 4963 msgCenter().cannotOpenSession(machine, progress); 4964 4965 /* Unlock machine, close session: */ 4968 4966 session.UnlockMachine(); 4969 4967 4968 /* True finally: */ 4970 4969 return true; 4971 4970 }
Note:
See TracChangeset
for help on using the changeset viewer.