VirtualBox

Ignore:
Timestamp:
Jul 1, 2009 2:25:14 PM (15 years ago)
Author:
vboxsync
Message:

crOpenGL: fix window/context management for multithreaded apps

Location:
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c

    r15532 r21127  
    140140        for (pos = 0; pos < CR_MAX_CONTEXTS; ++pos)
    141141            if (cr_server.curClient->contextList[pos] == ctx)
     142            {
    142143                cr_server.curClient->contextList[pos] = 0;
     144                break;
     145            }
     146        CRASSERT(pos<CR_MAX_CONTEXTS);
    143147    }
    144148}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c

    r17964 r21127  
    116116    int i, j;
    117117    int32_t pos;
    118 
    119     crDebug("Deleting client %p (%d msgs left)", client,
    120                     crNetNumMessages(client->conn));
     118    CRClient *oldclient = cr_server.curClient;
     119
     120    crDebug("Deleting client %p (%d msgs left)", client, crNetNumMessages(client->conn));
    121121
    122122#if 0
     
    142142        }
    143143    }
     144
     145    cr_server.curClient = client;
     146
     147    /* Destroy any windows created by the client */
     148    for (pos = 0; pos<CR_MAX_WINDOWS && client->windowList[pos]; pos++)
     149    {
     150        cr_server.dispatch.WindowDestroy(client->windowList[pos]);
     151    }
     152
     153    /* Check if we have context(s) made by this client left, could happen if client side code is lazy */
     154    for (pos = 0; pos<CR_MAX_CONTEXTS && client->contextList[pos]; pos++)
     155    {
     156        cr_server.dispatch.DestroyContext(client->contextList[pos]);
     157    }
     158
     159    cr_server.curClient = oldclient;
    144160
    145161    /* remove from the run queue */
     
    179195
    180196    crNetFreeConnection(client->conn);
    181 
    182     /* Destroy any windows created by the client */
    183     for (pos = 0; pos<CR_MAX_WINDOWS && client->windowList[pos]; pos++)
    184     {
    185         cr_server.dispatch.WindowDestroy(client->windowList[pos]);
    186     }
    187 
    188     /* Check if we have context(s) made by this client left, could happen if client side code is lazy */
    189     for (pos = 0; pos<CR_MAX_CONTEXTS && client->contextList[pos]; pos++)
    190     {
    191         cr_server.dispatch.DestroyContext(client->contextList[pos]);
    192     }
    193197
    194198    crFree(client);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r15532 r21127  
    119119}
    120120
    121 
    122 #define EXTRA_WARN 0
     121void crServerCheckCurrentCtxWindowCB(unsigned long key, void *data1, void *data2)
     122{
     123    CRContext *crCtx = (CRContext *) data1;
     124    GLint window = *(GLint*)data2;
     125
     126    (void) key;
     127}
    123128
    124129void SERVER_DISPATCH_APIENTRY
     
    130135    mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
    131136    if (!mural) {
    132 #if EXTRA_WARN
    133137         crWarning("CRServer: invalid window %d passed to WindowDestroy()", window);
    134 #endif
    135138         return;
    136139    }
     
    143146        for (pos = 0; pos < CR_MAX_WINDOWS; ++pos)
    144147            if (cr_server.curClient->windowList[pos] == window)
     148            {
    145149                cr_server.curClient->windowList[pos] = 0;
     150                break;
     151            }
     152        CRASSERT(pos<CR_MAX_WINDOWS);
    146153
    147154        if (cr_server.curClient->currentMural == mural)
     
    152159    }
    153160
     161    if (cr_server.currentWindow = window)
     162    {
     163        cr_server.currentWindow = -1;
     164    }
     165
     166    crHashtableWalk(cr_server.contextTable, crServerCheckCurrentCtxWindowCB, &window);
    154167    crHashtableDelete(cr_server.pWindowCreateInfoTable, window, crServerCreateInfoDeleteCB);
    155     /* @todo, can't issue it cause we could have context(s) referencing this one left */
    156     /*crHashtableDelete(cr_server.muralTable, window, crFree);*/
     168    crHashtableDelete(cr_server.muralTable, window, crFree);
    157169}
    158170
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