r24245 by jghali - Fix incorrect usage of icu::BreakIterator's setText()

scribus-commit scribus-commit at lists.scribus.net
Sat Nov 14 17:00:53 UTC 2020


Author: jghali
Date: Sat Nov 14 17:00:53 2020
New Revision: 24245

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24245
Log:
Fix incorrect usage of icu::BreakIterator's setText()

Modified:
    branches/Version156/Scribus/scribus/text/scworditerator.cpp
    branches/Version156/Scribus/scribus/text/scworditerator.h

Modified: branches/Version156/Scribus/scribus/text/scworditerator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24245&path=/branches/Version156/Scribus/scribus/text/scworditerator.cpp
==============================================================================
--- branches/Version156/Scribus/scribus/text/scworditerator.cpp	(original)
+++ branches/Version156/Scribus/scribus/text/scworditerator.cpp	Sat Nov 14 17:00:53 2020
@@ -23,6 +23,11 @@
 		delete m_wordIterator;
 		m_wordIterator = nullptr;
 	}
+	if (m_unicodeString)
+	{
+		delete m_unicodeString;
+		m_unicodeString = nullptr;
+	}
 }
 
 BreakIterator* ScWordIterator::getWordIterator()
@@ -39,7 +44,13 @@
 		return  nullptr;
 	}
 	
-	m_wordIterator->setText((const UChar*) m_story.plainText().utf16());
+	if (m_unicodeString)
+	{
+		delete m_unicodeString;
+		m_unicodeString = nullptr;
+	}
+	m_unicodeString = new icu::UnicodeString((const UChar*) m_story.plainText().utf16());
+	m_wordIterator->setText(*m_unicodeString);
 	return m_wordIterator;
 }
 

Modified: branches/Version156/Scribus/scribus/text/scworditerator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24245&path=/branches/Version156/Scribus/scribus/text/scworditerator.h
==============================================================================
--- branches/Version156/Scribus/scribus/text/scworditerator.h	(original)
+++ branches/Version156/Scribus/scribus/text/scworditerator.h	Sat Nov 14 17:00:53 2020
@@ -16,6 +16,7 @@
 
 U_NAMESPACE_BEGIN
 class BreakIterator;
+class UnicodeString;
 U_NAMESPACE_END
 
 class SCRIBUS_API ScWordIterator
@@ -32,6 +33,7 @@
 	QString word(int pos);
 	
 private:
+	icu::UnicodeString* m_unicodeString { nullptr };
 	icu::BreakIterator* m_wordIterator { nullptr };
 	StoryText& m_story;
 	




More information about the scribus-commit mailing list