r23424 by jghali - Avoid some useless textCursor() calls

scribus-commit scribus-commit at lists.scribus.net
Sat Dec 14 10:56:04 UTC 2019


Author: jghali
Date: Sat Dec 14 10:56:03 2019
New Revision: 23424

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23424
Log:
Avoid some useless textCursor() calls

Modified:
    trunk/Scribus/scribus/ui/storyeditor.cpp

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23424&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp	Sat Dec 14 10:56:03 2019
@@ -535,8 +535,9 @@
 
 void SEditor::insertChars(const QString& text)
 {
-	if (textCursor().hasSelection())
-		textCursor().removeSelectedText();
+	QTextCursor cursor = textCursor();
+	if (cursor.hasSelection())
+		cursor.removeSelectedText();
 	++blockContentsChangeHook;
 	QTextCursor c(textCursor());
 	int pos = qMin(c.position(), StyledText.length());
@@ -553,16 +554,17 @@
 {
 	if ((styledText.length() == editText.length()) && !styledText.isEmpty())
 	{
-		if (textCursor().hasSelection())
-			textCursor().removeSelectedText();
+		QTextCursor cursor1 = textCursor();
+		if (cursor1.hasSelection())
+			cursor1.removeSelectedText();
 
 		++blockContentsChangeHook;
-		QTextCursor cursor(textCursor());
-		int pos = qMin(cursor.position(), StyledText.length());
+		QTextCursor cursor2 = textCursor();
+		int pos = qMin(cursor2.position(), StyledText.length());
 		StyledText.insertChars(pos, styledText, true);
  		insertPlainText(editText);
-		cursor.setPosition(pos + editText.length());
-		setTextCursor(cursor);
+		cursor2.setPosition(pos + editText.length());
+		setTextCursor(cursor2);
 		--blockContentsChangeHook;
 	}
 }
@@ -571,15 +573,17 @@
 {
 	if (textCursor().hasSelection())
 		deleteSel();
-	int pos = textCursor().hasSelection() ? textCursor().selectionStart() : textCursor().position();
+	QTextCursor cursor = textCursor();
+	int pos = cursor.hasSelection() ? cursor.selectionStart() : cursor.position();
 	pos = qMin(pos, StyledText.length());
 	insertCharsInternal(t, pos);
 }
 
 void SEditor::insertCharsInternal(const QString& t, int pos)
 {
-	if (textCursor().hasSelection())
-		textCursor().removeSelectedText();
+	QTextCursor cursor = textCursor();
+	if (cursor.hasSelection())
+		cursor.removeSelectedText();
 	int oldLength = StyledText.length();
 	StyledText.insertChars(pos, t, true);
 	int newLength = StyledText.length();
@@ -590,7 +594,8 @@
 {
 	if (styledText.length() == 0)
 		return;
-	int pos = textCursor().hasSelection() ? textCursor().selectionStart() : textCursor().position();
+	QTextCursor cursor = textCursor();
+	int pos = cursor.hasSelection() ? cursor.selectionStart() : cursor.position();
 	pos = qMin(pos, StyledText.length());
 	insertStyledText(styledText, pos);
 }
@@ -599,8 +604,9 @@
 {
 	if (styledText.length() == 0)
 		return;
-	if (textCursor().hasSelection())
-		textCursor().removeSelectedText();
+	QTextCursor cursor = textCursor();
+	if (cursor.hasSelection())
+		cursor.removeSelectedText();
 	int oldLength = StyledText.length();
 	StyledText.insert(pos, styledText);
 	int newLength = StyledText.length();




More information about the scribus-commit mailing list