VirtualBox

Changeset 57748 in vbox for trunk/src


Ignore:
Timestamp:
Sep 14, 2015 6:41:40 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Main.cpp cleanup/rework bit-by-bit (step 2).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r57747 r57748  
    279279
    280280#ifdef Q_WS_X11
    281 /** This is a workaround for a bug on old libX11 versions, fixed in commit
    282  *      941f02ede63baa46f93ed8abccebe76fb29c0789 and released in version 1.1. */
    283 Status VBoxXInitThreads(void)
     281/** X11: For versions of Xlib which are aware of multi-threaded environments this function
     282  *      calls for XInitThreads() which initializes Xlib support for concurrent threads.
     283  * @returns @c non-zero unless it is unsafe to make multi-threaded calls to Xlib.
     284  * @remarks This is a workaround for a bug on old Xlib versions, fixed in commit
     285  *          941f02e and released in Xlib version 1.1. We check for the symbol
     286  *          "xcb_connect" which was introduced in that version. */
     287static Status MakeSureMultiThreadingIsSafe()
    284288{
    285     void *pvProcess = dlopen(NULL, RTLD_GLOBAL | RTLD_LAZY);
     289    /* Success by default: */
    286290    Status rc = 1;
     291    /* Get a global handle to process symbols: */
     292    void *pvProcess = dlopen(0, RTLD_GLOBAL | RTLD_LAZY);
     293    /* Initialize multi-thread environment only if we can obtain
     294     * an address of xcb_connect symbol in this process: */
    287295    if (pvProcess && dlsym(pvProcess, "xcb_connect"))
    288296        rc = XInitThreads();
     297    /* Close the handle: */
    289298    if (pvProcess)
    290299        dlclose(pvProcess);
     300    /* Return result: */
    291301    return rc;
    292302}
    293 #endif
     303#endif /* Q_WS_X11 */
    294304
    295305extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char ** /*envp*/)
     
    302312
    303313#ifdef Q_WS_X11
    304     if (!VBoxXInitThreads())
     314    if (!MakeSureMultiThreadingIsSafe())
    305315        return 1;
    306316#endif /* Q_WS_X11 */
     
    531541{
    532542#ifdef Q_WS_X11
    533     if (!VBoxXInitThreads())
     543    if (!MakeSureMultiThreadingIsSafe())
    534544        return 1;
    535545#endif /* Q_WS_X11 */
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