VirtualBox

Ignore:
Timestamp:
Jun 25, 2012 3:56:22 PM (13 years ago)
Author:
vboxsync
Message:

crOpenGL/OSX: fix concurency and freed memory reference

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r41865 r41913  
    264264- (NSView*)dockTileScreen;
    265265- (void)reshapeDockTile;
     266- (void)cleanupData;
    266267@end
    267268
     
    669670}
    670671
    671 - (void)dealloc
    672 {
    673     DEBUG_MSG(("OVIW(%p): dealloc OverlayView\n", (void*)self));
    674 
     672- (void)cleanupData
     673{
    675674    [self deleteFBO];
    676675
     
    679678        if ([m_pGLCtx view] == self)
    680679            [m_pGLCtx clearDrawable];
     680
     681        m_pGLCtx = nil;
    681682    }
    682683    if (m_pSharedGLCtx)
     
    686687
    687688        [m_pSharedGLCtx release];
     689
     690        m_pSharedGLCtx = nil;
    688691    }
    689692
    690693    [self clearVisibleRegions];
     694}
     695
     696- (void)dealloc
     697{
     698    DEBUG_MSG(("OVIW(%p): dealloc OverlayView\n", (void*)self));
     699
     700    [self cleanupData];
    691701
    692702    [super dealloc];
     
    701711{
    702712    DEBUG_MSG(("OVIW(%p): setGLCtx: new ctx: %p\n", (void*)self, (void*)pCtx));
     713    if (m_pGLCtx == pCtx)
     714        return;
     715
     716    /* ensure the context drawable is cleared to avoid holding a reference to inexistent view */
     717    if (m_pGLCtx)
     718        [m_pGLCtx clearDrawable];
    703719
    704720    m_pGLCtx = pCtx;
     
    17791795    [pWin setContentView: nil];
    17801796    [[pWin parentWindow] removeChildWindow: pWin];
     1797   
    17811798    /*
    17821799    a = [pWin retainCount];
     
    17841801        [pWin performSelector:@selector(release)]
    17851802    */
     1803    /* We can NOT run synchronously with the main thread since this may lead to a deadlock,
     1804       caused by main thread waiting xpcom thread, xpcom thread waiting to main hgcm thread,
     1805       and main hgcm thread waiting for us, this is why use waitUntilDone:NO,
     1806       which should cause no harm */
    17861807    [pWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
    17871808    /*
    17881809    [pWin release];
    17891810    */
     1811
     1812    /* We can NOT run synchronously with the main thread since this may lead to a deadlock,
     1813       caused by main thread waiting xpcom thread, xpcom thread waiting to main hgcm thread,
     1814       and main hgcm thread waiting for us, this is why use waitUntilDone:NO.
     1815       We need to avoid concurrency though, so we cleanup some data right away via a cleanupData call */
     1816    [(OverlayView*)pView cleanupData];
    17901817
    17911818    /* There seems to be a bug in the performSelector method which is called in
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