aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2004-04-26 02:59:00 +0000
committernyamatongwe <devnull@localhost>2004-04-26 02:59:00 +0000
commitc009cc2aa8817c6e0de696583ae2887e8c7c1d55 (patch)
tree77445239c33ed7c629b766e004afa9e10704e14c
parent7bf50e30a041a4dc2253bad7f88abe6e3c9c1eb5 (diff)
downloadscintilla-mirror-c009cc2aa8817c6e0de696583ae2887e8c7c1d55.tar.gz
Extra safety if ClipBoard already opened or allocation fails.
-rw-r--r--win32/ScintillaWin.cxx10
1 files changed, 6 insertions, 4 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 1bb297652..2c0a7e7ef 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1114,10 +1114,11 @@ bool ScintillaWin::CanPaste() {
}
void ScintillaWin::Paste() {
+ if (!::OpenClipboard(MainHWND()))
+ return;
pdoc->BeginUndoAction();
int selStart = SelectionStart();
ClearSelection();
- ::OpenClipboard(MainHWND());
bool isRectangular = ::IsClipboardFormatAvailable(cfColumnSelect) != 0;
HGLOBAL hmemUSelection = 0;
if (IsUnicodeMode()) {
@@ -1592,7 +1593,8 @@ void ScintillaWin::GetIntelliMouseParameters() {
}
void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
- ::OpenClipboard(MainHWND());
+ if (!::OpenClipboard(MainHWND()))
+ return;
::EmptyClipboard();
HGLOBAL hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
@@ -1601,8 +1603,8 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
char *ptr = static_cast<char *>(::GlobalLock(hand));
memcpy(ptr, selectedText.s, selectedText.len);
::GlobalUnlock(hand);
+ ::SetClipboardData(CF_TEXT, hand);
}
- ::SetClipboardData(CF_TEXT, hand);
if (IsUnicodeMode()) {
int uchars = UCS2Length(selectedText.s, selectedText.len);
@@ -1612,8 +1614,8 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
wchar_t *uptr = static_cast<wchar_t *>(::GlobalLock(uhand));
UCS2FromUTF8(selectedText.s, selectedText.len, uptr, uchars);
::GlobalUnlock(uhand);
+ ::SetClipboardData(CF_UNICODETEXT, uhand);
}
- ::SetClipboardData(CF_UNICODETEXT, uhand);
}
if (selectedText.rectangular) {