Changeset 45435 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 9, 2013 2:05:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r45377 r45435 525 525 #ifndef VBOX_WITH_HARDENING 526 526 527 int main 527 int main(int argc, char **argv, char **envp) 528 528 { 529 /* Initialize VBox Runtime. Initialize the SUPLib as well only if we530 * are really about to start a VM. Don't do this if we are only starting531 * the selector window. */529 /* Initialize VBox Runtime. 530 * Initialize the SUPLib as well only if we are really about to start a VM. 531 * Don't do this if we are only starting the selector window. */ 532 532 bool fInitSUPLib = false; 533 for (int i = 1; i < argc; i++)533 for (int i = 1; i < argc; ++i) 534 534 { 535 535 /* NOTE: the check here must match the corresponding check for the … … 543 543 } 544 544 } 545 546 545 int rc = RTR3InitExe(argc, &argv, fInitSUPLib ? RTR3INIT_FLAGS_SUPLIB : 0); 546 547 /* Initialization failed: */ 547 548 if (RT_FAILURE(rc)) 548 549 { 549 QApplication a (argc, &argv[0]); 550 /* We have to create QApplication anyway 551 * just to show the only one error-message: */ 552 QApplication a(argc, &argv[0]); 550 553 #ifdef Q_OS_SOLARIS 551 /* Use plastique look 'n feel for Solaris instead of the default motif (Qt 4.7.x) */ 552 QApplication::setStyle (new QPlastiqueStyle); 553 #endif 554 QString msgTitle = QApplication::tr ("VirtualBox - Runtime Error"); 555 QString msgText = "<html>"; 556 554 /* Use plastique look&feel for Solaris instead of the default motif (Qt 4.7.x): */ 555 QApplication::setStyle(new QPlastiqueStyle); 556 #endif /* Q_OS_SOLARIS */ 557 558 /* Prepare the error-message: */ 559 QString strTitle = QApplication::tr("VirtualBox - Runtime Error"); 560 QString strText = "<html>"; 557 561 switch (rc) 558 562 { 559 563 case VERR_VM_DRIVER_NOT_INSTALLED: 560 564 case VERR_VM_DRIVER_LOAD_ERROR: 561 msgText += QApplication::tr ( 562 "<b>Cannot access the kernel driver!</b><br/><br/>"); 565 strText += QApplication::tr("<b>Cannot access the kernel driver!</b><br/><br/>"); 563 566 # ifdef RT_OS_LINUX 564 msgText += g_QStrHintLinuxNoDriver;565 # else 566 msgText += g_QStrHintOtherNoDriver;567 # endif 567 strText += g_QStrHintLinuxNoDriver; 568 # else /* RT_OS_LINUX */ 569 strText += g_QStrHintOtherNoDriver; 570 # endif /* !RT_OS_LINUX */ 568 571 break; 569 572 # ifdef RT_OS_LINUX 570 573 case VERR_NO_MEMORY: 571 msgText += g_QStrHintLinuxNoMemory;574 strText += g_QStrHintLinuxNoMemory; 572 575 break; 573 # endif 576 # endif /* RT_OS_LINUX */ 574 577 case VERR_VM_DRIVER_NOT_ACCESSIBLE: 575 msgText += QApplication::tr("Kernel driver not accessible");578 strText += QApplication::tr("Kernel driver not accessible"); 576 579 break; 577 580 case VERR_VM_DRIVER_VERSION_MISMATCH: 578 581 # ifdef RT_OS_LINUX 579 msgText += g_QStrHintLinuxWrongDriverVersion;580 # else 581 msgText += g_QStrHintOtherWrongDriverVersion;582 # endif 582 strText += g_QStrHintLinuxWrongDriverVersion; 583 # else /* RT_OS_LINUX */ 584 strText += g_QStrHintOtherWrongDriverVersion; 585 # endif /* !RT_OS_LINUX */ 583 586 break; 584 587 default: 585 msgText += QApplication::tr ( 586 "Unknown error %2 during initialization of the Runtime" 587 ).arg (rc); 588 strText += QApplication::tr("Unknown error %2 during initialization of the Runtime").arg(rc); 588 589 break; 589 590 } 590 msgText += "</html>";591 QMessageBox::critical ( 592 0, /* parent*/593 msgTitle,594 msgText,595 QMessageBox::Abort, /* button0 */ 596 0); /* button1*/591 strText += "</html>"; 592 593 /* Show the error-message: */ 594 QMessageBox::critical(0 /* parent */, strTitle, strText, 595 QMessageBox::Abort /* 1st button */, 0 /* 2nd button */); 596 597 /* Default error-result: */ 597 598 return 1; 598 599 } 599 600 600 return TrustedMain (argc, argv, envp); 601 /* Actual main function: */ 602 return TrustedMain(argc, argv, envp); 601 603 } 602 604 603 605 #else /* VBOX_WITH_HARDENING */ 604 606 605 /** 606 * Hardened main failed, report the error without any unnecessary fuzz. 607 * 608 * @remarks Do not call IPRT here unless really required, it might not be 609 * initialized. 610 */ 611 extern "C" DECLEXPORT(void) TrustedError (const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, va_list va) 607 extern "C" DECLEXPORT(void) TrustedError(const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, va_list va) 612 608 { 613 # if defined(RT_OS_DARWIN)609 # ifdef RT_OS_DARWIN 614 610 ShutUpAppKit(); 615 # endif 616 617 /* 618 * Init the Qt application object. This is a bit hackish as we 619 * don't have the argument vector handy. 620 */ 611 # endif /* RT_OS_DARWIN */ 612 613 /* We have to create QApplication anyway just to show the only one error-message. 614 * This is a bit hackish as we don't have the argument vector handy. */ 621 615 int argc = 0; 622 616 char *argv[2] = { NULL, NULL }; 623 QApplication a (argc, &argv[0]); 624 625 /* 626 * Compose and show the error message. 627 */ 628 QString msgTitle = QApplication::tr ("VirtualBox - Error In %1").arg (pszWhere); 629 617 QApplication a(argc, &argv[0]); 618 619 /* Prepare the error-message: */ 620 QString strTitle = QApplication::tr("VirtualBox - Error In %1").arg(pszWhere); 630 621 char msgBuf[1024]; 631 vsprintf (msgBuf, pszMsgFmt, va); 632 633 QString msgText = QApplication::tr ( 634 "<html><b>%1 (rc=%2)</b><br/><br/>").arg (msgBuf).arg (rc); 622 vsprintf(msgBuf, pszMsgFmt, va); 623 QString strText = QApplication::tr("<html><b>%1 (rc=%2)</b><br/><br/>").arg(msgBuf).arg(rc); 635 624 switch (enmWhat) 636 625 { 637 626 case kSupInitOp_Driver: 638 627 # ifdef RT_OS_LINUX 639 msgText += g_QStrHintLinuxNoDriver;640 # else 641 msgText += g_QStrHintOtherNoDriver;642 # endif 628 strText += g_QStrHintLinuxNoDriver; 629 # else /* RT_OS_LINUX */ 630 strText += g_QStrHintOtherNoDriver; 631 # endif /* !RT_OS_LINUX */ 643 632 break; 644 633 # ifdef RT_OS_LINUX 645 634 case kSupInitOp_IPRT: 646 635 if (rc == VERR_NO_MEMORY) 647 msgText += g_QStrHintLinuxNoMemory;636 strText += g_QStrHintLinuxNoMemory; 648 637 else 649 # endif 638 # endif /* RT_OS_LINUX */ 650 639 if (rc == VERR_VM_DRIVER_VERSION_MISMATCH) 651 640 # ifdef RT_OS_LINUX 652 msgText += g_QStrHintLinuxWrongDriverVersion;653 # else 654 msgText += g_QStrHintOtherWrongDriverVersion;655 # endif 641 strText += g_QStrHintLinuxWrongDriverVersion; 642 # else /* RT_OS_LINUX */ 643 strText += g_QStrHintOtherWrongDriverVersion; 644 # endif /* !RT_OS_LINUX */ 656 645 else 657 msgText += g_QStrHintReinstall;646 strText += g_QStrHintReinstall; 658 647 break; 659 648 case kSupInitOp_Integrity: 660 649 case kSupInitOp_RootCheck: 661 msgText += g_QStrHintReinstall;650 strText += g_QStrHintReinstall; 662 651 break; 663 652 default: … … 665 654 break; 666 655 } 667 msgText += "</html>";656 strText += "</html>"; 668 657 669 658 # ifdef RT_OS_LINUX 659 /* We have to to make sure that we display the error-message 660 * after the parent displayed its own message. */ 670 661 sleep(2); 671 # endif 672 QMessageBox::critical ( 673 0, /* parent */ 674 msgTitle, /* title */ 675 msgText, /* text */ 676 QMessageBox::Abort, /* button0 */ 677 0); /* button1 */ 678 qFatal ("%s", msgText.toAscii().constData()); 662 # endif /* RT_OS_LINUX */ 663 664 QMessageBox::critical(0 /* parent */, strTitle, strText, 665 QMessageBox::Abort /* 1st button */, 0 /* 2nd button */); 666 qFatal("%s", strText.toAscii().constData()); 679 667 } 680 668
Note:
See TracChangeset
for help on using the changeset viewer.