瀏覽代碼

Fixed crash when trying to copy with empty selection

Ivan Safrin 13 年之前
父節點
當前提交
9344384708
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      Modules/Contents/UI/Source/PolyUITextInput.cpp

+ 6 - 1
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -802,6 +802,9 @@ String UITextInput::getLineText(unsigned int index) {
 }       
 
 String UITextInput::getSelectionText() {
+	if(!hasSelection)
+		return L"";
+		
 	String totalText = L"";
 	if(selectionTop == selectionBottom) {
 		totalText = lines[selectionTop]->getText().substr(selectionL, selectionR-selectionL);	
@@ -887,7 +890,9 @@ void UITextInput::Cut() {
 }
 
 void UITextInput::Copy() {
-	CoreServices::getInstance()->getCore()->copyStringToClipboard(getSelectionText());	
+	if(hasSelection) {
+		CoreServices::getInstance()->getCore()->copyStringToClipboard(getSelectionText());
+	}
 }
 
 void UITextInput::Paste() {