VirtualBox

Changeset 21481 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 10, 2009 2:14:36 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49920
Message:

FE/Qt4: better approach

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited

Legend:

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

    r20078 r21481  
    266266    bool isValid() { return mValid; }
    267267
     268    static QString qtRTVersionString();
     269    static uint qtRTVersion();
     270    static QString qtCTVersionString();
     271    static uint qtCTVersion();
     272
    268273    QString versionString() { return mVerString; }
    269274
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r21479 r21481  
    646646    qDeleteAll (mVMStateIcons);
    647647    qDeleteAll (mVMStateColors);
     648}
     649
     650/* static */
     651QString VBoxGlobal::qtRTVersionString()
     652{
     653    return QString::fromLatin1 (qVersion());
     654}
     655
     656/* static */
     657uint VBoxGlobal::qtRTVersion()
     658{
     659    QString rt_ver_str = VBoxGlobal::qtRTVersionString();
     660    return (rt_ver_str.section ('.', 0, 0).toInt() << 16) +
     661           (rt_ver_str.section ('.', 1, 1).toInt() << 8) +
     662           rt_ver_str.section ('.', 2, 2).toInt();
     663}
     664
     665/* static */
     666QString VBoxGlobal::qtCTVersionString()
     667{
     668    return QString::fromLatin1 (QT_VERSION_STR);
     669}
     670
     671/* static */
     672uint VBoxGlobal::qtCTVersion()
     673{
     674    QString ct_ver_str = VBoxGlobal::qtCTVersionString();
     675    return (ct_ver_str.section ('.', 0, 0).toInt() << 16) +
     676           (ct_ver_str.section ('.', 1, 1).toInt() << 8) +
     677           ct_ver_str.section ('.', 2, 2).toInt();
    648678}
    649679
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r21480 r21481  
    324324    /* scope the QIApplication variable */
    325325    {
    326 #if defined(Q_WS_X11) && (QT_VERSION >= 0x040500)
     326#ifdef Q_WS_X11
    327327        /* There are some buggy/strange driver/compiz combinations which lead
    328328         * to transparent backgrounds on ARGB visuals. Try to fix it by not
     
    330330         * restore the original environment, so that others like the OpenGL
    331331         * service will proper work. */
    332         RTENV env = NIL_RTENV;
    333         char envval[1024];
    334         bool found = false;
    335         int rc = RTEnvClone (&env, RTENV_DEFAULT);
    336         if (RT_SUCCESS (rc))
    337         {
    338             found = RTEnvGetEx (env, "XLIB_SKIP_ARGB_VISUALS", envval, sizeof(envval), NULL) == VINF_SUCCESS;
    339             RTEnvSetEx (env, "XLIB_SKIP_ARGB_VISUALS", "1");
     332        char *pchOldVar = NULL;
     333        if (!RTEnvExist ("VBOX_NO_ARGB_VISUALS_HACK") &&
     334            VBoxGlobal::qtRTVersion() >= 0x040500)
     335        {
     336            const char *pchVar = RTEnvGet ("XLIB_SKIP_ARGB_VISUALS");
     337            if (pchVar)
     338                pchOldVar = RTStrDup (pchVar);
     339            RTEnvSet ("XLIB_SKIP_ARGB_VISUALS", "1");
    340340        }
    341341        /* Now create the application object */
    342342        QIApplication a (argc, argv);
    343343        /* Restore previous environment */
    344         if (env != NIL_RTENV)
    345         {
    346             if (found)
    347                 RTEnvSetEx (env, "XLIB_SKIP_ARGB_VISUALS", envval);
    348             else
    349                 RTEnvUnsetEx (env, "XLIB_SKIP_ARGB_VISUALS");
    350             RTEnvDestroy (env);
     344        if (pchOldVar)
     345        {
     346            RTEnvSet ("XLIB_SKIP_ARGB_VISUALS", pchOldVar);
     347            RTStrFree (pchOldVar);
    351348        }
    352349#else /* defined(Q_WS_X11) && (QT_VERSION >= 0x040500) */
     
    422419#ifdef Q_WS_X11
    423420        /* version check (major.minor are sensitive, fix number is ignored) */
    424         QString ver_str = QString::fromLatin1 (QT_VERSION_STR);
    425         QString ver_str_base = ver_str.section ('.', 0, 1);
    426         QString rt_ver_str = QString::fromLatin1 (qVersion());
    427         uint ver =
    428             (ver_str.section ('.', 0, 0).toInt() << 16) +
    429             (ver_str.section ('.', 1, 1).toInt() << 8) +
    430             ver_str.section ('.', 2, 2).toInt();
    431         uint rt_ver =
    432             (rt_ver_str.section ('.', 0, 0).toInt() << 16) +
    433             (rt_ver_str.section ('.', 1, 1).toInt() << 8) +
    434             rt_ver_str.section ('.', 2, 2).toInt();
    435         if (rt_ver < (ver & 0xFFFF00))
     421        if (VBoxGlobal::qtRTVersion() < (VBoxGlobal::qtCTVersion() & 0xFFFF00))
    436422        {
    437423            QString msg =
    438424                QApplication::tr ("Executable <b>%1</b> requires Qt %2.x, found Qt %3.")
    439425                                  .arg (qAppName())
    440                                   .arg (ver_str_base)
    441                                   .arg (rt_ver_str);
     426                                  .arg (VBoxGlobal::qtCTVersionString().section ('.', 0, 1))
     427                                  .arg (VBoxGlobal::qtRTVersionString());
    442428            QMessageBox::critical (
    443429                0, QApplication::tr ("Incompatible Qt Library Error"),
Note: See TracChangeset for help on using the changeset viewer.

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