VirtualBox

Changeset 100665 in vbox for trunk


Ignore:
Timestamp:
Jul 20, 2023 1:20:29 PM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158505
Message:

Shared Clipboard: More Windows data object refcount bugfixes. Added VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS for helping tracking down those issues. bugref:9437

Location:
trunk/src/VBox/GuestHost/SharedClipboard
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp

    r100664 r100665  
    4949#include <iprt/errcore.h>
    5050#include <VBox/log.h>
     51
     52/** Enable this to track the current counts of the data / stream / enum object we create + supply to the Windows clipboard.
     53 *  Helps finding refcount issues or tracking down memory leaks. */
     54#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     55 int g_cDbgDataObj;
     56 int g_cDbgStreamObj;
     57 int g_cDbgEnumFmtObj;
     58#endif
    5159
    5260/** @todo Also handle Unicode entries.
     
    6674    , m_EventStatusChanged(NIL_RTSEMEVENT)
    6775{
     76#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     77    g_cDbgDataObj++;
     78    LogFlowFunc(("g_cDataObj=%d, g_cStreamObj=%d, g_cEnumFmtObj=%d\n", g_cDbgDataObj, g_cDbgStreamObj, g_cDbgEnumFmtObj));
     79#endif
    6880}
    6981
     
    7183{
    7284    Destroy();
     85
     86#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     87    g_cDbgDataObj--;
     88    LogFlowFunc(("g_cDataObj=%d, g_cStreamObj=%d, g_cEnumFmtObj=%d\n", g_cDbgDataObj, g_cDbgStreamObj, g_cDbgEnumFmtObj));
     89#endif
    7390
    7491    LogFlowFunc(("mRefCount=%RI32\n", m_lRefCount));
     
    250267
    251268    if (m_pStream)
    252     {
    253         m_pStream->Release();
    254269        m_pStream = NULL;
    255     }
    256270
    257271    if (m_pFormatEtc)
  • trunk/src/VBox/GuestHost/SharedClipboard/ClipboardEnumFormatEtcImpl-win.cpp

    r100204 r100665  
    4040
    4141
     42/*********************************************************************************************************************************
     43*   Structures and Typedefs                                                                                                      *
     44*********************************************************************************************************************************/
     45
     46
     47
     48/*********************************************************************************************************************************
     49*   Static variables                                                                                                             *
     50*********************************************************************************************************************************/
     51#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     52 extern int g_cDbgDataObj;
     53 extern int g_cDbgStreamObj;
     54 extern int g_cDbgEnumFmtObj;
     55#endif
     56
    4257
    4358SharedClipboardWinEnumFormatEtc::SharedClipboardWinEnumFormatEtc(void)
     
    4560      m_nIndex(0)
    4661{
     62#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     63    g_cDbgEnumFmtObj++;
     64    LogFlowFunc(("g_cDataObj=%d, g_cStreamObj=%d, g_cEnumFmtObj=%d\n", g_cDbgDataObj, g_cDbgStreamObj, g_cDbgEnumFmtObj));
     65#endif
    4766}
    4867
     
    5271
    5372    LogFlowFunc(("m_lRefCount=%RI32\n", m_lRefCount));
     73
     74#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     75    g_cDbgEnumFmtObj--;
     76    LogFlowFunc(("g_cDataObj=%d, g_cStreamObj=%d, g_cEnumFmtObj=%d\n", g_cDbgDataObj, g_cDbgStreamObj, g_cDbgEnumFmtObj));
     77#endif
    5478}
    5579
  • trunk/src/VBox/GuestHost/SharedClipboard/ClipboardStreamImpl-win.cpp

    r100509 r100665  
    5252*   Static variables                                                                                                             *
    5353*********************************************************************************************************************************/
    54 
     54#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     55 extern int g_cDbgDataObj;
     56 extern int g_cDbgStreamObj;
     57 extern int g_cDbgEnumFmtObj;
     58#endif
    5559
    5660
     
    6973
    7074    LogFunc(("m_strPath=%s\n", m_strPath.c_str()));
     75
     76#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     77    g_cDbgStreamObj++;
     78    LogFlowFunc(("g_cDataObj=%d, g_cStreamObj=%d, g_cEnumFmtObj=%d\n", g_cDbgDataObj, g_cDbgStreamObj, g_cDbgEnumFmtObj));
     79#endif
    7180}
    7281
     
    7483{
    7584    LogFlowThisFuncEnter();
     85
     86#ifdef VBOX_SHARED_CLIPBOARD_DEBUG_OBJECT_COUNTS
     87    g_cDbgStreamObj--;
     88    LogFlowFunc(("g_cDataObj=%d, g_cStreamObj=%d, g_cEnumFmtObj=%d\n", g_cDbgDataObj, g_cDbgStreamObj, g_cDbgEnumFmtObj));
     89#endif
    7690}
    7791
     
    376390    if (pStream)
    377391    {
    378         pStream->AddRef();
    379 
    380392        *ppStream = pStream;
    381393        return S_OK;
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp

    r100661 r100665  
    10651065    if (RT_SUCCESS(rc))
    10661066    {
    1067         if (pWinCtx->pDataObjInFlight == NULL)
    1068         {
    1069             SharedClipboardWinDataObject *pObj = new SharedClipboardWinDataObject();
    1070             if (pObj)
     1067        LogFlowFunc(("pWinCtx->pDataObjInFlight=%p\n", pWinCtx->pDataObjInFlight));
     1068
     1069        /* Create a new data object here, assign it as the the current data object in-flight and
     1070         * announce it to Windows below.
     1071         *
     1072         * The data object will be deleted automatically once its refcount reaches 0.
     1073         */
     1074        SharedClipboardWinDataObject *pObj = new SharedClipboardWinDataObject();
     1075        if (pObj)
     1076        {
     1077            rc = pObj->Init(pCtx, pCallbacks);
     1078            if (RT_SUCCESS(rc))
    10711079            {
    1072                 rc = pObj->Init(pCtx, pCallbacks);
    10731080                if (RT_SUCCESS(rc))
    1074                 {
    1075                     if (RT_SUCCESS(rc))
    1076                         pWinCtx->pDataObjInFlight = pObj;
    1077                 }
     1081                    pWinCtx->pDataObjInFlight = pObj;
    10781082            }
    1079             else
    1080                 rc = VERR_NO_MEMORY;
    1081         }
     1083        }
     1084        else
     1085            rc = VERR_NO_MEMORY;
    10821086
    10831087        if (RT_SUCCESS(rc))
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