Browse Source

Missing null checks and small style fixes

plClipboard
Bartek Bok 13 years ago
parent
commit
a99ed37f23
  1. 25
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp
  2. 7
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp

25
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp

@ -511,18 +511,23 @@ hsBool pfGUIEditBoxMod::HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef
else if (key == KEY_V) else if (key == KEY_V)
{ {
wchar_t* contents = plClipboard::GetInstance().GetClipboardText(); wchar_t* contents = plClipboard::GetInstance().GetClipboardText();
size_t len = wcslen(contents); if (contents != nil)
if (len > 0) { {
wchar_t* insertTarget = fBuffer + fCursorPos; size_t len = wcslen(contents);
size_t bufferTailLen = wcslen(insertTarget); if (len > 0)
if (fCursorPos + len + bufferTailLen < fBufferSize) { {
memmove(insertTarget + len, insertTarget, bufferTailLen * sizeof(wchar_t)); wchar_t* insertTarget = fBuffer + fCursorPos;
memcpy(insertTarget, contents, len * sizeof(wchar_t)); size_t bufferTailLen = wcslen(insertTarget);
fCursorPos += len; if (fCursorPos + len + bufferTailLen < fBufferSize)
HandleExtendedEvent( kValueChanging ); {
memmove(insertTarget + len, insertTarget, bufferTailLen * sizeof(wchar_t));
memcpy(insertTarget, contents, len * sizeof(wchar_t));
fCursorPos += len;
HandleExtendedEvent( kValueChanging );
}
} }
delete contents;
} }
delete contents;
} }
} }
else else

7
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp

@ -1226,8 +1226,11 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyEvent( pfGameGUIMgr::EventType event, pl
else if (key == KEY_V) else if (key == KEY_V)
{ {
wchar_t* contents = plClipboard::GetInstance().GetClipboardText(); wchar_t* contents = plClipboard::GetInstance().GetClipboardText();
InsertString(contents); if (contents != nil)
delete contents; {
InsertString(contents);
delete contents;
}
} }
} }
else else

Loading…
Cancel
Save