VirtualBox

Changeset 48906 in vbox for trunk


Ignore:
Timestamp:
Oct 5, 2013 10:39:42 PM (11 years ago)
Author:
vboxsync
Message:

GUI: Prevent cleanup race in VBoxGlobal media-enumerator-mess from crashing again during termination.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
1 added
5 edited

Legend:

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

    r48826 r48906  
    2525#include <QDesktopServices>
    2626#include <QMutex>
     27#include <QReadLocker>
    2728#include <QToolButton>
    2829#include <QProcess>
     
    943944
    944945        /* Search for corresponding UI medium again: */
     946
    945947        uimedium = medium(strMediumID);
    946948        if (uimedium.isNull())
     
    16641666{
    16651667    /* Create medium in medium-enumerator: */
    1666     m_pMediumEnumerator->createMedium(medium);
     1668    QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
     1669    if (m_pMediumEnumerator)
     1670        m_pMediumEnumerator->createMedium(medium);
    16671671}
    16681672
     
    16701674{
    16711675    /* Update medium of medium-enumerator: */
    1672     m_pMediumEnumerator->updateMedium(medium);
     1676    QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
     1677    if (m_pMediumEnumerator)
     1678        m_pMediumEnumerator->updateMedium(medium);
    16731679}
    16741680
     
    16761682{
    16771683    /* Delete medium from medium-enumerator: */
    1678     m_pMediumEnumerator->deleteMedium(strMediumID);
     1684    QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
     1685    if (m_pMediumEnumerator)
     1686        m_pMediumEnumerator->deleteMedium(strMediumID);
    16791687}
    16801688
     
    18411849
    18421850    /* Redirect request to medium-enumerator: */
    1843     m_pMediumEnumerator->enumerateMediums();
     1851    QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
     1852    if (m_pMediumEnumerator)
     1853        m_pMediumEnumerator->enumerateMediums();
    18441854}
    18451855
     
    18471857{
    18481858    /* Redirect request to medium-enumerator: */
    1849     return m_pMediumEnumerator->isMediumEnumerationInProgress();
     1859    return m_pMediumEnumerator
     1860        && m_pMediumEnumerator->isMediumEnumerationInProgress();
    18501861}
    18511862
     
    18531864{
    18541865    /* Redirect call to medium-enumerator: */
    1855     return m_pMediumEnumerator->medium(strMediumID);
     1866    QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
     1867    if (m_pMediumEnumerator)
     1868        return m_pMediumEnumerator->medium(strMediumID);
     1869    return UIMedium();
    18561870}
    18571871
     
    18591873{
    18601874    /* Redirect call to medium-enumerator: */
    1861     return m_pMediumEnumerator->mediumIDs();
     1875    QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
     1876    if (m_pMediumEnumerator)
     1877        return m_pMediumEnumerator->mediumIDs();
     1878    return QList<QString>();
    18621879}
    18631880
     
    43524369
    43534370    /* Cleanup medium-enumerator: */
     4371    m_mediumEnumeratorDtorRwLock.lockForWrite();
    43544372    delete m_pMediumEnumerator;
    43554373    m_pMediumEnumerator = 0;
     4374    m_mediumEnumeratorDtorRwLock.unlock();
    43564375
    43574376    if (mSelectorWnd)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r48314 r48906  
    11/** @file
    2  *
    3  * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VBoxGlobal class declaration
     2 * VBox Qt GUI - VBoxGlobal class declaration.
    53 */
    64
     
    1715 */
    1816
    19 #ifndef __VBoxGlobal_h__
    20 #define __VBoxGlobal_h__
     17#ifndef ___VBoxGlobal_h___
     18#define ___VBoxGlobal_h___
    2119
    2220/* Qt includes: */
     
    2725#include <QHash>
    2826#include <QFileIconProvider>
     27#include <QReadWriteLock>
    2928#ifdef Q_WS_MAC
    3029# include <QSet>
     
    7372
    7473    bool isValid() { return mValid; }
     74    bool isCleaningUp() { return m_sfCleanupInProgress; }
    7575
    7676    static QString qtRTVersionString();
     
    429429    /* Variable: Medium-enumeration stuff: */
    430430    UIMediumEnumerator *m_pMediumEnumerator;
     431    mutable QReadWriteLock m_mediumEnumeratorDtorRwLock;
    431432
    432433    RenderMode vm_render_mode;
     
    509510inline VBoxGlobal& vboxGlobal() { return *VBoxGlobal::instance(); }
    510511
    511 #endif /* __VBoxGlobal_h__ */
    512 
     512#endif /* !___VBoxGlobal_h___ */
     513
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.cpp

    r48893 r48906  
    11/* $Id$ */
    22/** @file
    3  *
    4  * VBox frontends: Qt GUI ("VirtualBox"):
    5  * UIMediumEnumerator class implementation
     3 * VBox Qt GUI - UIMediumEnumerator class implementation.
    64 */
    75
     
    166164    addMediumsToMap(vboxGlobal().host().GetFloppyDrives(), mediums, UIMediumType_Floppy);
    167165    addMediumsToMap(vboxGlobal().virtualBox().GetFloppyImages(), mediums, UIMediumType_Floppy);
     166    if (vboxGlobal().isCleaningUp())
     167        return; /* VBoxGlobal is cleaning up, abort immediately. */
    168168    m_mediums = mediums;
    169169
     
    316316    foreach (CMedium medium, inputMediums)
    317317    {
     318        /* If VBoxGlobal is cleaning up, abort immediately: */
     319        if (vboxGlobal().isCleaningUp())
     320            break;
     321
    318322        /* Prepare uimedium on the basis of current medium: */
    319323        QString strMediumID = medium.GetId();
     
    332336    foreach (CMedium medium, inputMediums)
    333337    {
     338        /* If VBoxGlobal is cleaning up, abort immediately: */
     339        if (vboxGlobal().isCleaningUp())
     340            break;
     341
    334342        /* Prepare uimedium on the basis of current medium: */
    335343        QString strMediumID = medium.GetId();
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.h

    r48276 r48906  
    11/** @file
    2  *
    3  * VBox frontends: Qt GUI ("VirtualBox"):
    4  * UIMediumEnumerator class declaration
     2 * VBox Qt GUI - UIMediumEnumerator class declaration.
    53 */
    64
     
    1715 */
    1816
    19 #ifndef __UIMediumEnumerator_h__
    20 #define __UIMediumEnumerator_h__
     17#ifndef ___UIMediumEnumerator_h___
     18#define ___UIMediumEnumerator_h___
    2119
    2220/* Qt includes: */
     
    8886};
    8987
    90 #endif /* __UIMediumEnumerator_h__ */
     88#endif /* !___UIMediumEnumerator_h___ */
     89
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r48831 r48906  
    6262UIGDetailsElementInterface::~UIGDetailsElementInterface()
    6363{
     64    /* VBoxGlobal must still be valid at this point, otherwise our thread might
     65       be doing really bad things to already deleted memory! */
     66    Assert(vboxGlobal().isValid());
     67    Assert(!vboxGlobal().isCleaningUp());
     68
    6469    cleanupThread();
    6570}
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