VirtualBox

Changeset 57364 in vbox


Ignore:
Timestamp:
Aug 14, 2015 5:28:03 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
102127
Message:

FE/Qt: Main event handling: Protect COM cleanup procedure with read-write lock.

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

Legend:

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

    r55554 r57364  
    2222/* GUI includes: */
    2323# include "UIMainEventListener.h"
     24# include "VBoxGlobal.h"
    2425
    2526/* COM includes: */
     
    6768STDMETHODIMP UIMainEventListener::HandleEvent(VBoxEventType_T /* type */, IEvent *pEvent)
    6869{
     70    /* Try to acquire COM cleanup protection token first: */
     71    if (!vboxGlobal().comTokenTryLockForRead())
     72        return S_OK;
     73
    6974    CEvent event(pEvent);
    7075    // printf("Event received: %d\n", event.GetType());
     
    264269        default: break;
    265270    }
     271
     272    /* Unlock COM cleanup protection token: */
     273    vboxGlobal().comTokenUnlock();
     274
    266275    return S_OK;
    267276}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r57099 r57364  
    43824382    mTypes.clear();
    43834383
    4384     /* the last steps to ensure we don't use COM any more */
    4385     m_host.detach();
    4386     m_vbox.detach();
    4387     m_client.detach();
    4388 
    4389     /* There may be UIMedium(s)EnumeratedEvent instances still in the message
    4390      * queue which reference COM objects. Remove them to release those objects
    4391      * before uninitializing the COM subsystem. */
    4392     QApplication::removePostedEvents (this);
    4393 
    4394     COMBase::CleanupCOM();
     4384    /* Starting COM cleanup: */
     4385    m_comCleanupProtectionToken.lockForWrite();
     4386    {
     4387        /* First, make sure we don't use COM any more: */
     4388        m_host.detach();
     4389        m_vbox.detach();
     4390        m_client.detach();
     4391
     4392        /* There may be UIMedium(s)EnumeratedEvent instances still in the message
     4393         * queue which reference COM objects. Remove them to release those objects
     4394         * before uninitializing the COM subsystem. */
     4395        QApplication::removePostedEvents(this);
     4396
     4397        /* Finally cleanup COM itself: */
     4398        COMBase::CleanupCOM();
     4399    }
     4400    /* Finishing COM cleanup: */
     4401    m_comCleanupProtectionToken.unlock();
    43954402
    43964403    /* Destroy popup-center: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r57099 r57364  
    120120#endif /* Q_WS_MAC */
    121121
     122    /** Try to acquire COM cleanup protection token for reading. */
     123    bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); }
     124    /** Unlock previously acquired COM cleanup protection token. */
     125    void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); }
     126
    122127    /** Returns the copy of VirtualBox client wrapper. */
    123128    CVirtualBoxClient virtualBoxClient() const { return m_client; }
     
    481486
    482487    bool mValid;
     488
     489    /** COM cleanup protection token. */
     490    QReadWriteLock m_comCleanupProtectionToken;
    483491
    484492    /** Holds the instance of VirtualBox client wrapper. */
Note: See TracChangeset for help on using the changeset viewer.

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