Changeset 45439 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 9, 2013 2:44:03 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r45435 r45439 299 299 } 300 300 301 extern "C" DECLEXPORT(int) TrustedMain 301 extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char ** /*envp*/) 302 302 { 303 /* Start logging: */ 303 304 LogFlowFuncEnter(); 304 # if defined(RT_OS_DARWIN) 305 306 # ifdef RT_OS_DARWIN 305 307 ShutUpAppKit(); 306 # endif 307 308 # endif /* RT_OS_DARWIN */ 309 310 /* Console help preprocessing: */ 308 311 for (int i=0; i<argc; i++) 309 312 if ( !strcmp(argv[i], "-h") … … 317 320 318 321 #if defined(DEBUG) && defined(Q_WS_X11) && defined(RT_OS_LINUX) 319 /* install our signal handler to backtrace the call stack*/322 /* Install our signal handler to backtrace the call stack: */ 320 323 struct sigaction sa; 321 324 sa.sa_sigaction = bt_sighandler; 322 sigemptyset 325 sigemptyset(&sa.sa_mask); 323 326 sa.sa_flags = SA_RESTART | SA_SIGINFO; 324 sigaction 325 sigaction 326 sigaction 327 sigaction(SIGSEGV, &sa, NULL); 328 sigaction(SIGBUS, &sa, NULL); 329 sigaction(SIGUSR1, &sa, NULL); 327 330 #endif 328 331 … … 331 334 * forces NSApplication to be instantiated. */ 332 335 UICocoaApplication::instance(); 333 #endif 334 335 qInstallMsgHandler 336 #endif /* QT_MAC_USE_COCOA */ 337 338 qInstallMsgHandler(QtMessageOutput); 336 339 337 340 int rc = 1; /* failure */ 338 341 339 /* scope the QApplication variable*/342 /* Scope the QApplication variable: */ 340 343 { 341 344 #ifdef Q_WS_X11 342 345 /* Qt has a complex algorithm for selecting the right visual which 343 * doesn't always seem to work. 344 * default one - ourselves and pass that to Qt. 346 * doesn't always seem to work. So we naively choose a visual - the 347 * default one - ourselves and pass that to Qt. This means that we 345 348 * also have to open the display ourselves. 346 349 * We check the Qt parameter list and handle Qt's -display argument 347 * ourselves, since we open the display connection. 350 * ourselves, since we open the display connection. We also check the 348 351 * to see if the user has passed Qt's -visual parameter, and if so we 349 352 * assume that the user wants Qt to handle visual selection after all, … … 354 357 { 355 358 if (!::strcmp(argv[i], "-display") && (i + 1 < argc)) 356 /* What if it isn't? 359 /* What if it isn't? Rely on QApplication to complain? */ 357 360 { 358 361 pszDisplay = argv[i + 1]; … … 373 376 ? DefaultVisual(pDisplay, DefaultScreen(pDisplay)) 374 377 : NULL; 375 /* Now create the application object */376 QApplication a (pDisplay, argc, argv, (Qt::HANDLE)pVisual);378 /* Now create the application object: */ 379 QApplication a(pDisplay, argc, argv, (Qt::HANDLE)pVisual); 377 380 #else /* Q_WS_X11 */ 378 QApplication a 381 QApplication a(argc, argv); 379 382 #endif /* Q_WS_X11 */ 380 383 381 UIModalWindowManager::create();382 383 /* Qt4.3 version has the QProcess bug which freezing the application384 * for 30 seconds. This bug is internally used at initialization of385 * Cleanlooks style. So we have to change this style to another one.386 * See http://trolltech.com/developer/task-tracker/index_html?id=179200&method=entry387 * for details. */388 if (VBoxGlobal::qtRTVersionString().startsWith ("4.3") &&389 qobject_cast <QCleanlooksStyle*> (QApplication::style()))390 QApplication::setStyle (new QPlastiqueStyle);391 392 384 #ifdef Q_OS_SOLARIS 393 /* Use plastique look 'n feel for Solaris instead of the default motif (Qt 4.7.x)*/394 QApplication::setStyle 395 #endif 385 /* Use plastique look&feel for Solaris instead of the default motif (Qt 4.7.x): */ 386 QApplication::setStyle(new QPlastiqueStyle); 387 #endif /* Q_OS_SOLARIS */ 396 388 397 389 #ifdef Q_WS_X11 398 390 /* This patch is not used for now on Solaris & OpenSolaris because 399 391 * there is no anti-aliasing enabled by default, Qt4 to be rebuilt. */ 400 # ifndef Q_OS_SOLARIS392 # ifndef Q_OS_SOLARIS 401 393 /* Cause Qt4 has the conflict with fontconfig application as a result 402 394 * sometimes substituting some fonts with non scaleable-anti-aliased … … 405 397 QFontDatabase fontDataBase; 406 398 407 QString currentFamily (QApplication::font().family()); 408 bool isCurrentScaleable = fontDataBase.isScalable (currentFamily); 409 410 /* 411 LogFlowFunc (("Font: Current family is '%s'. It is %s.\n", 412 currentFamily.toLatin1().constData(), 413 isCurrentScaleable ? "scalable" : "not scalable")); 414 QStringList subFamilies (QFont::substitutes (currentFamily)); 415 foreach (QString sub, subFamilies) 416 { 417 bool isSubScalable = fontDataBase.isScalable (sub); 418 LogFlowFunc (("Font: Substitute family is '%s'. It is %s.\n", 419 sub.toLatin1().constData(), 420 isSubScalable ? "scalable" : "not scalable")); 421 } 422 */ 399 QString currentFamily(QApplication::font().family()); 400 bool isCurrentScaleable = fontDataBase.isScalable(currentFamily); 423 401 424 402 QString subFamily (QFont::substitute (currentFamily)); … … 427 405 if (isCurrentScaleable && !isSubScaleable) 428 406 QFont::removeSubstitution (currentFamily); 429 # endif /* Q_OS_SOLARIS */430 #endif 407 # endif /* Q_OS_SOLARIS */ 408 #endif /* Q_WS_X11 */ 431 409 432 410 #ifdef Q_WS_WIN … … 437 415 * load and slows down the load process that happens on the main GUI 438 416 * thread to several seconds). */ 439 PlaySound 440 #endif 417 PlaySound(NULL, NULL, 0); 418 #endif /* Q_WS_WIN */ 441 419 442 420 #ifdef Q_WS_MAC 421 /* Disable menu icons on MacOS X host: */ 443 422 ::darwinDisableIconsInMenus(); 444 423 #endif /* Q_WS_MAC */ 445 424 446 425 #ifdef Q_WS_X11 447 /* version check (major.minor are sensitive, fix number is ignored)*/426 /* Qt version check (major.minor are sensitive, fix number is ignored): */ 448 427 if (VBoxGlobal::qtRTVersion() < (VBoxGlobal::qtCTVersion() & 0xFFFF00)) 449 428 { 450 QString msg = 451 QApplication::tr ("Executable <b>%1</b> requires Qt %2.x, found Qt %3.") 452 .arg (qAppName()) 453 .arg (VBoxGlobal::qtCTVersionString().section ('.', 0, 1)) 454 .arg (VBoxGlobal::qtRTVersionString()); 455 QMessageBox::critical ( 456 0, QApplication::tr ("Incompatible Qt Library Error"), 457 msg, QMessageBox::Abort, 0); 458 qFatal ("%s", msg.toAscii().constData()); 429 QString strMsg = QApplication::tr("Executable <b>%1</b> requires Qt %2.x, found Qt %3.") 430 .arg(qAppName()) 431 .arg(VBoxGlobal::qtCTVersionString().section('.', 0, 1)) 432 .arg(VBoxGlobal::qtRTVersionString()); 433 QMessageBox::critical(0, QApplication::tr("Incompatible Qt Library Error"), 434 strMsg, QMessageBox::Abort, 0); 435 qFatal("%s", strMsg.toAscii().constData()); 459 436 } 460 #endif 461 462 /* load a translation based on the current locale */ 437 #endif /* Q_WS_X11 */ 438 439 /* Create modal-window manager: */ 440 UIModalWindowManager::create(); 441 442 /* Load a translation based on the current locale: */ 463 443 VBoxGlobal::loadLanguage(); 464 444 445 /* Simulate try-catch block: */ 465 446 do 466 447 { 448 /* Exit if VBoxGlobal is not valid: */ 467 449 if (!vboxGlobal().isValid()) 468 450 break; 469 451 470 452 /* Exit if VBoxGlobal unable to process arguments: */ 471 453 if (vboxGlobal().processArgs()) 472 454 return 0; … … 477 459 #endif /* RT_OS_LINUX */ 478 460 461 /* Load application settings: */ 479 462 VBoxGlobalSettings settings = vboxGlobal().settings(); 480 /* Process known keys */ 481 bool noSelector = settings.isFeatureActive ("noSelector"); 482 463 464 /* VM console process: */ 483 465 if (vboxGlobal().isVMConsoleProcess()) 484 466 { 485 if (vboxGlobal().startMachine(vboxGlobal().managedVMUuid()))486 rc = a.exec();487 }488 else if (noSelector) 489 {490 msgCenter().cannotStartSelector();467 /* Make sure VM is started: */ 468 if (!vboxGlobal().startMachine(vboxGlobal().managedVMUuid())) 469 break; 470 471 /* Start application: */ 472 rc = a.exec(); 491 473 } 492 474 else 493 475 { 476 /* Make sure VM selector is permitted: */ 477 if (settings.isFeatureActive("noSelector")) 478 { 479 msgCenter().cannotStartSelector(); 480 break; 481 } 482 494 483 #ifdef VBOX_BLEEDING_EDGE 495 484 msgCenter().showBEBWarning(); 496 485 #else /* VBOX_BLEEDING_EDGE */ 497 486 # ifndef DEBUG 498 /* Check for BETA version */499 QString vboxVersion 500 if (vboxVersion.contains 487 /* Check for BETA version: */ 488 QString vboxVersion(vboxGlobal().virtualBox().GetVersion()); 489 if (vboxVersion.contains("BETA")) 501 490 { 502 /* Allow to prevent this message */ 503 QString str = vboxGlobal().virtualBox(). 504 GetExtraData(GUI_PreventBetaWarning); 491 /* Allow to prevent this message: */ 492 QString str = vboxGlobal().virtualBox().GetExtraData(GUI_PreventBetaWarning); 505 493 if (str != vboxVersion) 506 494 msgCenter().showBETAWarning(); … … 508 496 # endif /* !DEBUG */ 509 497 #endif /* !VBOX_BLEEDING_EDGE*/ 498 499 /* Create/show selector window: */ 510 500 vboxGlobal().selectorWnd().show(); 501 502 /* Start application: */ 511 503 rc = a.exec(); 512 504 } … … 514 506 while (0); 515 507 508 /* Create modal-window manager: */ 516 509 UIModalWindowManager::destroy(); 517 510 } 518 511 519 LogFlowFunc (("rc=%d\n", rc)); 512 /* Finish logging: */ 513 LogFlowFunc(("rc=%d\n", rc)); 520 514 LogFlowFuncLeave(); 521 515 516 /* Return result: */ 522 517 return rc; 523 518 }
Note:
See TracChangeset
for help on using the changeset viewer.