Skip to content

Commit

Permalink
For Windows, fixes some issues in the ClipboardExtended plugin platfo…
Browse files Browse the repository at this point in the history
…rm code. Every OpenClipboard must have a CloseClipboard or we would lock out other applications.
  • Loading branch information
marceltaeumel committed Mar 22, 2023
1 parent 0dd0229 commit 9624ac8
Showing 1 changed file with 17 additions and 14 deletions.
Expand Up @@ -30,37 +30,38 @@ typedef void *CLIPBOARDTYPE;
void
sqPasteboardClear(CLIPBOARDTYPE inPasteboard)
{
(void)OpenClipboard(NULL);
(void)EmptyClipboard();
if (!OpenClipboard(myWindow())) {
interpreterProxy->primitiveFailFor(PrimErrOperationFailed);
return;
}
if (!EmptyClipboard()) {
CloseClipboard();
interpreterProxy->primitiveFailFor(PrimErrOperationFailed);
return;
}
CloseClipboard();
}

sqInt
sqPasteboardGetItemCount(CLIPBOARDTYPE inPasteboard)
{
#if 0
UINT count = 0, format = 0, lastFormat = 0;
UINT count = 0;

if (!OpenClipboard(myWindow())) {
interpreterProxy->primitiveFailFor(PrimErrOperationFailed);
return 0;
}
while ((format = EnumClipboardFormats(lastFormat))) {
lastFormat = format;
++count;
}
CloseClipboard(NULL);
return count;
#else
return CountClipboardFormats();
#endif
count = CountClipboardFormats();
CloseClipboard();
return count;
}

sqInt
sqPasteboardCopyItemFlavorsitemNumber(CLIPBOARDTYPE inPasteboard, sqInt formatNumber)
{
UINT count = 0, format = 0, lastFormat = 0;

if (formatNumber < 1
if (formatNumber < 0
|| !OpenClipboard(myWindow())) {
interpreterProxy->primitiveFailFor(PrimErrOperationFailed);
return 0;
Expand Down Expand Up @@ -98,6 +99,7 @@ sqPasteboardPutItemFlavordatalengthformatType(CLIPBOARDTYPE inPasteboard, char *
return;
}
if (format == CF_BITMAP) {
CloseClipboard();
interpreterProxy->primitiveFailFor(PrimErrUnsupported);
return;
}
Expand All @@ -106,6 +108,7 @@ sqPasteboardPutItemFlavordatalengthformatType(CLIPBOARDTYPE inPasteboard, char *
if (format == CF_UTF8TEXT) {
int numWchars = MultiByteToWideChar(CP_UTF8, 0, inData, dataLength, 0, 0);
if (numWchars < 0) {
CloseClipboard();
interpreterProxy->primitiveFailForOSError(GetLastError());
return;
}
Expand Down

0 comments on commit 9624ac8

Please sign in to comment.