浏览代码

Update client/eventsSDL/InputSourceKeyboard.cpp

Co-authored-by: Ivan Savenko <[email protected]>
Michael 2 年之前
父节点
当前提交
e8771e40a5
共有 1 个文件被更改,包括 9 次插入6 次删除
  1. 9 6
      client/eventsSDL/InputSourceKeyboard.cpp

+ 9 - 6
client/eventsSDL/InputSourceKeyboard.cpp

@@ -33,12 +33,15 @@ void InputSourceKeyboard::handleEventKeyDown(const SDL_KeyboardEvent & key)
 {
 	if (SDL_IsTextInputActive() == SDL_TRUE)
 	{
-		if(key.keysym.sym == SDLK_v && isKeyboardCtrlDown()) {
-		        std::string clipboardContent = SDL_GetClipboardText();
-		        boost::erase_all(clipboardContent, "\r");
-		        boost::erase_all(clipboardContent, "\n");
-		        GH.events().dispatchTextInput(clipboardContent);
-		        return;
+		if(key.keysym.sym == SDLK_v && isKeyboardCtrlDown()) 
+		{
+			char * clipboardBuffer = SDL_GetClipboardText();
+			std::string clipboardContent = clipboardBuffer;
+			boost::erase_all(clipboardContent, "\r");
+			boost::erase_all(clipboardContent, "\n");
+			GH.events().dispatchTextInput(clipboardContent);
+			SDL_free(clipboardBuffer);
+			return;
 	 	}
 
 		if (key.keysym.sym >= ' ' && key.keysym.sym < 0x80)