VirtualBox

Changeset 85834 in vbox


Ignore:
Timestamp:
Aug 19, 2020 2:05:37 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139994
Message:

Shared Clipboard/X11: Return VERR_NO_DATA in X11 callback implementations to make it easier to spot that there is no data available.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp

    r85798 r85834  
    8080
    8181/**
    82  * Get clipboard data from the host.
     82 * Callback implementation for getting clipboard data from the host.
    8383 *
    84  * @returns VBox result code
     84 * @returns VBox status code. VERR_NO_DATA if no data available.
    8585 * @param   pCtx                Our context information.
    8686 * @param   Format              The format of the data being requested.
    8787 * @param   ppv                 On success and if pcb > 0, this will point to a buffer
    8888 *                              to be freed with RTMemFree containing the data read.
    89  * @param   pcb                 On success, this contains the number of bytes of data
    90  *                              returned.
     89 * @param   pcb                 On success, this contains the number of bytes of data returned.
    9190 */
    9291DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb)
     
    138137        }
    139138
     139        if (!cbRead)
     140            rc = VERR_NO_DATA;
     141
    140142        if (RT_SUCCESS(rc))
    141143        {
     
    143145            *ppv = pvData;
    144146        }
    145 
    146         /*
    147          * Catch other errors. This also catches the case in which the buffer was
    148          * too small a second time, possibly because the clipboard contents
    149          * changed half-way through the operation.  Since we can't say whether or
    150          * not this is actually an error, we just return size 0.
    151          */
    152         if (RT_FAILURE(rc))
     147        else
     148        {
     149            /*
     150             * Catch other errors. This also catches the case in which the buffer was
     151             * too small a second time, possibly because the clipboard contents
     152             * changed half-way through the operation.  Since we can't say whether or
     153             * not this is actually an error, we just return size 0.
     154             */
    153155            RTMemFree(pvData);
     156        }
    154157    }
    155158
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r85773 r85834  
    316316
    317317/**
    318  * Reads clipboard data from the guest and passes it to the X11 clipboard.
     318 * Callback implementation for reading clipboard data from the guest.
    319319 *
    320320 * @note   Runs in Xt event thread.
    321321 *
    322  * @param  pCtx      Pointer to the host clipboard structure.
    323  * @param  fFormat   The format in which the data should be transferred
    324  *                   (VBOX_SHCL_FMT_XXX).
    325  * @param  ppv       On success and if pcb > 0, this will point to a buffer
    326  *                   to be freed with RTMemFree containing the data read.
    327  * @param  pcb       On success, this contains the number of bytes of data
    328  *                   returned.
     322 * @returns VBox status code. VERR_NO_DATA if no data available.
     323 * @param   pCtx                Pointer to the host clipboard structure.
     324 * @param   fFormat             The format in which the data should be transferred
     325 *                              (VBOX_SHCL_FMT_XXX).
     326 * @param   ppv                 On success and if pcb > 0, this will point to a buffer
     327 *                              to be freed with RTMemFree containing the data read.
     328 * @param   pcb                 On success, this contains the number of bytes of data returned.
    329329 */
    330330DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT fFormat, void **ppv, uint32_t *pcb)
     
    356356            if (RT_SUCCESS(rc))
    357357            {
    358                 *ppv = pPayload ? pPayload->pvData : NULL;
    359                 *pcb = pPayload ? pPayload->cbData : 0;
     358                if (   !pPayload
     359                    || !pPayload->cbData)
     360                {
     361                    rc = VERR_NO_DATA;
     362                }
     363                else
     364                {
     365                    *ppv = pPayload->pvData;
     366                    *pcb = pPayload->cbData;
     367                }
    360368            }
    361369
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