View Issue Details

IDProjectCategoryView StatusLast Update
0016864ScribusImport / Exportpublic2022-11-25 17:02
Reporterwilliam Assigned Tocbradney  
PrioritynormalSeveritycrashReproducibilityrandom
Status resolvedResolutionfixed 
Product Version1.7.0.svn 
Fixed in Version1.7.0.svn 
Summary0016864: Scribus crashes opening sla files
Descriptionscribus150format.cpp has a number of places that set QStringView tagName = reader.name() as it parses the sla file. https://doc.qt.io/qt-6/qstringview.html notes that "A QStringView references a contiguous portion of a UTF-16 string it does not own. When QStringViews are used as automatic variables or data members, care must be taken to ensure that the referenced string data (for example, owned by a QString) outlives the QStringView on all code paths, lest the string view ends up referencing deleted data." After creating the QStringView tagName, following calls to read tokens from the QXmlStreamReader can invalidate the buffer that the QStringView tagName points to. Usually Scribus150Format won't crash, but it will mess up the parse, for example, not extracting any layers, and then scribus will crash later. The attached patch changes all of the QStringView tags to QStrings. Some of them might be ok as QStringView, but it is probably safer to change them all.
Steps To ReproduceOpen a 1.5 or higher SLA with scribus 1.7. Since it depends on random memory inherited by the scribus process, it can work ok for a number of tries, and then crash for a number of tries. It might also depend on the malloc library. Since valgrind replaces malloc, the crashes do not happen under valgrind, which makes the bad accesses harder to track down. I am using gcc 12.2.1 on Fedora 36 x86_64, but this bug has been causing problems over a range of scribus and Fedora releases, maybe since the first scribus 1.7 release.
TagsNo tags attached.
PatchYes

Activities

william

2022-11-24 07:19

updater  

scribus17p3-scribus150format-qstringview-20221124-071340.patch (21,133 bytes)   
 scribus/plugins/fileloader/scribus150format/scribus150format.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
index f54d6a7b8..42198bd23 100644
--- a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
+++ b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
@@ -320,7 +320,7 @@ bool Scribus150Format::loadElements(const QString& data, const QString& fileDir,
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		attrs = reader.scAttributes();
 
 		if (firstElement)
@@ -846,7 +846,7 @@ bool Scribus150Format::loadStory(const QByteArray& data, StoryText& story, PageI
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		attrs = reader.scAttributes();
 
 		if (firstElement)
@@ -1072,7 +1072,7 @@ bool Scribus150Format::loadPalette(const QString & fileName)
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		attrs = reader.scAttributes();
 
 		if (m_mwProgressBar != nullptr)
@@ -1662,7 +1662,7 @@ bool Scribus150Format::loadFile(const QString & fileName, const FileFormat & /*
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		attrs = reader.scAttributes();
 
 		if (m_mwProgressBar != nullptr)
@@ -2706,7 +2706,7 @@ bool Scribus150Format::readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader)
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		if (reader.isStartElement())
 			attrs = reader.attributes();
 		if (reader.isEndElement() && tagName == QLatin1String("PageSets"))
@@ -2832,7 +2832,7 @@ bool Scribus150Format::readGradient(ScribusDoc *doc, VGradient &gra, ScXmlStream
 	gra = VGradient(VGradient::linear);
 	gra.clearStops();
 	ScXmlStreamAttributes rattrs = reader.scAttributes();
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		ScXmlStreamReader::TokenType tType = reader.readNext();
@@ -3208,7 +3208,7 @@ void Scribus150Format::readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& re
 	//	newStyle.tabValues().clear();
 	QList<ParagraphStyle::TabRecord> tbs;
 	newStyle.resetTabValues();
-	QStringView thisTagName = reader.name();
+	QString thisTagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3251,7 +3251,7 @@ void Scribus150Format::readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader
 		newStyle.setFillColor(attrs.valueAsString("FillColor"));
 	if (attrs.hasAttribute("FillShade"))
 		newStyle.setFillShade(attrs.valueAsDouble("FillShade"));
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3260,7 +3260,7 @@ void Scribus150Format::readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader
 		if (reader.name() == QLatin1String("TableBorderLeft"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3281,7 +3281,7 @@ void Scribus150Format::readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader
 		else if (reader.name() == QLatin1String("TableBorderRight"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3302,7 +3302,7 @@ void Scribus150Format::readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader
 		else if (reader.name() == QLatin1String("TableBorderTop"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3323,7 +3323,7 @@ void Scribus150Format::readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader
 		else if (reader.name() == QLatin1String("TableBorderBottom"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3372,7 +3372,7 @@ void Scribus150Format::readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader,
 	if (attrs.hasAttribute("BottomPadding"))
 		newStyle.setBottomPadding(attrs.valueAsDouble("BottomPadding", 0.0));
 
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3381,7 +3381,7 @@ void Scribus150Format::readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader,
 		if (reader.name() == QLatin1String("TableBorderLeft"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3402,7 +3402,7 @@ void Scribus150Format::readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader,
 		else if (reader.name() == QLatin1String("TableBorderRight"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3423,7 +3423,7 @@ void Scribus150Format::readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader,
 		else if (reader.name() == QLatin1String("TableBorderTop"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3444,7 +3444,7 @@ void Scribus150Format::readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader,
 		else if (reader.name() == QLatin1String("TableBorderBottom"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -3506,7 +3506,7 @@ bool Scribus150Format::readMultiline(multiLine& ml, ScXmlStreamReader& reader)
 {
 	ml = multiLine();
 	ScXmlStreamAttributes rattrs = reader.scAttributes();
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		ScXmlStreamReader::TokenType tType = reader.readNext();
@@ -3615,7 +3615,7 @@ bool Scribus150Format::readPDFOptions(ScribusDoc* doc, ScXmlStreamReader& reader
 	doc->pdfOptions().PageLayout    = attrs.valueAsInt("PageLayout", 0);
 	doc->pdfOptions().openAction    = attrs.valueAsString("openAction", "");
 
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3623,7 +3623,7 @@ bool Scribus150Format::readPDFOptions(ScribusDoc* doc, ScXmlStreamReader& reader
 			break;
 		if (!reader.isStartElement())
 			continue;
-		QStringView tName = reader.name();
+		QString tName = reader.name().toString();
 		attrs = reader.scAttributes();
 		if (tName == QLatin1String("LPI"))
 		{
@@ -3705,11 +3705,11 @@ bool Scribus150Format::readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& re
 	doc->Print_Options.printerCommand = attrs.valueAsString("printerCommand");
 	doc->Print_Options.copies = 1;
 
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		ScXmlStreamReader::TokenType tType = reader.readNext();
-		QStringView tName = reader.name();
+		QString tName = reader.name().toString();
 		if (tType == ScXmlStreamReader::StartElement && tName == QLatin1String("Separation"))
 			doc->Print_Options.allSeparations.append(reader.attributes().value("Name").toString());
 		if (tType == ScXmlStreamReader::EndElement && tName == tagName)
@@ -3720,7 +3720,7 @@ bool Scribus150Format::readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& re
 
 bool Scribus150Format::readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader& reader)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	doc->clearItemAttributes();
 	while (!reader.atEnd() && !reader.hasError())
 	{
@@ -3746,7 +3746,7 @@ bool Scribus150Format::readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader&
 
 bool Scribus150Format::readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	m_Doc->clearTocSetups();
 	while (!reader.atEnd() && !reader.hasError())
 	{
@@ -3777,7 +3777,7 @@ bool Scribus150Format::readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& r
 
 bool Scribus150Format::readNotesStyles(ScribusDoc* doc, ScXmlStreamReader& reader)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3848,7 +3848,7 @@ bool Scribus150Format::readNotesStyles(ScribusDoc* doc, ScXmlStreamReader& reade
 bool Scribus150Format::readNotesFrames(ScXmlStreamReader& reader)
 {
 	notesFramesData.clear();
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3880,7 +3880,7 @@ bool Scribus150Format::readNotesFrames(ScXmlStreamReader& reader)
 bool Scribus150Format::readNotes(ScribusDoc* doc, ScXmlStreamReader& reader)
 {
 	//read notes
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3902,7 +3902,7 @@ bool Scribus150Format::readNotes(ScribusDoc* doc, ScXmlStreamReader& reader)
 
 bool Scribus150Format::readMarks(ScribusDoc* doc, ScXmlStreamReader& reader)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -3954,7 +3954,7 @@ bool Scribus150Format::readMarks(ScribusDoc* doc, ScXmlStreamReader& reader)
 
 bool Scribus150Format::readSections(ScribusDoc* doc, ScXmlStreamReader& reader)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -4013,7 +4013,7 @@ bool Scribus150Format::readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader)
 	if (!doc->docHyphenator)
 		doc->createHyphenator();
 
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -4038,7 +4038,7 @@ bool Scribus150Format::readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader)
 
 bool Scribus150Format::readPage(ScribusDoc* doc, ScXmlStreamReader& reader)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 
 	ScXmlStreamAttributes attrs = reader.scAttributes();
 	int     pageNum  = attrs.valueAsInt("NUM");
@@ -4123,7 +4123,7 @@ bool Scribus150Format::readPage(ScribusDoc* doc, ScXmlStreamReader& reader)
 
 bool Scribus150Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, const ReadObjectParams& readObjectParams, ItemInfo& info)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	ScXmlStreamAttributes attrs = reader.scAttributes();
 
 	bool savedMasterPageMode = doc->masterPageMode();
@@ -4230,7 +4230,7 @@ bool Scribus150Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, co
 			break;
 		if (tType != ScXmlStreamReader::StartElement)
 			continue;
-		QStringView tName = reader.name();
+		QString tName = reader.name().toString();
 		ScXmlStreamAttributes tAtt = reader.scAttributes();
 		if (tName == QLatin1String("CSTOP"))
 		{
@@ -4699,7 +4699,7 @@ bool Scribus150Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 	m_Doc->setMasterPageMode(false);
 	int itemCount1 = m_Doc->Items->count();
 
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	while (!reader.atEnd() && !reader.hasError())
 	{
 		reader.readNext();
@@ -4918,7 +4918,7 @@ bool Scribus150Format::readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, c
 
 bool Scribus150Format::readStoryText(ScribusDoc *doc, ScXmlStreamReader& reader, StoryText& story, PageItem* item)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	ScXmlStreamAttributes attrs = reader.scAttributes();
 
 	LastStyles * lastStyle = new LastStyles();
@@ -4929,7 +4929,7 @@ bool Scribus150Format::readStoryText(ScribusDoc *doc, ScXmlStreamReader& reader,
 			break;
 		if (tType != ScXmlStreamReader::StartElement)
 			continue;
-		QStringView tName = reader.name();
+		QString tName = reader.name().toString();
 		ScXmlStreamAttributes tAtt = reader.scAttributes();
 
 		if (tName == QLatin1String("DefaultStyle"))
@@ -5201,7 +5201,7 @@ bool Scribus150Format::readItemText(StoryText& story, ScXmlStreamAttributes& att
 
 bool Scribus150Format::readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	ObjAttrVector pageItemAttributes;
 	while (!reader.atEnd() && !reader.hasError())
 	{
@@ -6138,7 +6138,7 @@ bool Scribus150Format::readItemTableData(PageItem_Table* item, ScXmlStreamReader
 	if ((fColor != CommonStrings::None) && (!fColor.isEmpty()))
 		item->setFillColor(fColor);
 	item->setFillShade(attrs.valueAsInt("FillShade", 100));
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	LastStyles lastStyle;
 	doc->dontResize = true;
 	while (!reader.atEnd() && !reader.hasError())
@@ -6156,7 +6156,7 @@ bool Scribus150Format::readItemTableData(PageItem_Table* item, ScXmlStreamReader
 		else if (reader.name() == QLatin1String("TableBorderLeft"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6177,7 +6177,7 @@ bool Scribus150Format::readItemTableData(PageItem_Table* item, ScXmlStreamReader
 		else if (reader.name() == QLatin1String("TableBorderRight"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6198,7 +6198,7 @@ bool Scribus150Format::readItemTableData(PageItem_Table* item, ScXmlStreamReader
 		else if (reader.name() == QLatin1String("TableBorderTop"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6219,7 +6219,7 @@ bool Scribus150Format::readItemTableData(PageItem_Table* item, ScXmlStreamReader
 		else if (reader.name() == QLatin1String("TableBorderBottom"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6250,7 +6250,7 @@ bool Scribus150Format::readItemTableData(PageItem_Table* item, ScXmlStreamReader
 
 bool Scribus150Format::readItemTableCell(PageItem_Table* item, ScXmlStreamReader& reader, ScribusDoc *doc)
 {
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 	ScXmlStreamAttributes tAtt = reader.scAttributes();
 	
 	int row = tAtt.valueAsInt("Row", -1);
@@ -6301,7 +6301,7 @@ bool Scribus150Format::readItemTableCell(PageItem_Table* item, ScXmlStreamReader
 		if (reader.name() == QLatin1String("TableBorderLeft"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6322,7 +6322,7 @@ bool Scribus150Format::readItemTableCell(PageItem_Table* item, ScXmlStreamReader
 		else if (reader.name() == QLatin1String("TableBorderRight"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6343,7 +6343,7 @@ bool Scribus150Format::readItemTableCell(PageItem_Table* item, ScXmlStreamReader
 		else if (reader.name() == QLatin1String("TableBorderTop"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6364,7 +6364,7 @@ bool Scribus150Format::readItemTableCell(PageItem_Table* item, ScXmlStreamReader
 		else if (reader.name() == QLatin1String("TableBorderBottom"))
 		{
 			TableBorder border;
-			QStringView tagName = reader.name();
+			QString tagName = reader.name().toString();
 			while (!reader.atEnd() && !reader.hasError())
 			{
 				reader.readNext();
@@ -6399,7 +6399,7 @@ bool Scribus150Format::readItemTableCell(PageItem_Table* item, ScXmlStreamReader
 bool Scribus150Format::readLatexInfo(PageItem_LatexFrame* latexitem, ScXmlStreamReader& reader)
 {
 	ScXmlStreamAttributes attrs = reader.scAttributes();
-	QStringView tagName = reader.name();
+	QString tagName = reader.name().toString();
 
 	latexitem->setConfigFile(attrs.valueAsString("ConfigFile"), true);
 	latexitem->setDpi(attrs.valueAsInt("DPI"));
@@ -6520,7 +6520,7 @@ bool Scribus150Format::loadPage(const QString & fileName, int pageNumber, bool M
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		attrs = reader.scAttributes();
 
 		if (firstElement)
@@ -7244,7 +7244,7 @@ bool Scribus150Format::readStyles(const QString& fileName, ScribusDoc* doc, Styl
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		if (firstElement)
 		{
 			if (tagName != QLatin1String("SCRIBUSUTF8NEW"))
@@ -7284,7 +7284,7 @@ bool Scribus150Format::readCharStyles(const QString& fileName, ScribusDoc* doc,
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		if (firstElement)
 		{
 			if (tagName != QLatin1String("SCRIBUSUTF8NEW"))
@@ -7322,7 +7322,7 @@ bool Scribus150Format::readLineStyles(const QString& fileName, QHash<QString,mul
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		if (firstElement)
 		{
 			if (tagName != QLatin1String("SCRIBUSUTF8NEW"))
@@ -7372,7 +7372,7 @@ bool Scribus150Format::readColors(const QString& fileName, ColorList & colors)
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		if (firstElement)
 		{
 			if (tagName != QLatin1String("SCRIBUSUTF8NEW"))
@@ -7419,7 +7419,7 @@ bool Scribus150Format::readPageCount(const QString& fileName, int *num1, int *nu
 		QXmlStreamReader::TokenType tType = reader.readNext();
 		if (tType != QXmlStreamReader::StartElement)
 			continue;
-		QStringView tagName = reader.name();
+		QString tagName = reader.name().toString();
 		if (firstElement)
 		{
 			if (tagName != QLatin1String("SCRIBUSUTF8NEW"))

ale

2022-11-24 15:36

manager   ~0049817

here 1.7 crashes each time it tries to open its own (simplest) files.

william

2022-11-24 17:54

updater   ~0049818

@ale That is why I didn't send an example. At first, I thought that my old SLA files were the problem, but I opened scribus without a file, made a new empty document, saved it, and closed scribus, and then when I tried opening the new document, scribus crashed. scribus 1.7 has been crashing randomly for me opening documents since I first tried building it in June 2022. `git blame scribus150format.cpp | grep QStringView` shows that the issue goes back at least to January 2022. It's nice to know that I'm not the only one affected. Can you test if my patch fixes the crashes for you?

ale

2022-11-24 20:31

manager   ~0049819

yep, no crash after having applied your patch!
good catch.

btw, i wonder, how expensive it is to create all those QLatin1String in a tight loop...
(won't matter for normal documents, but it might be noticeable with vectorized text)

cbradney

2022-11-24 20:46

administrator   ~0049820

Thanks William. Jean and I have been working on this one for a bit. It's escaped us due to not being replicable on Windows and sometimes on some OSes. Jean had a patch, so I combined it with some other minor changes. Its fixed for 1.5.x/1.7.x docs in r25188.

cbradney

2022-11-24 21:13

administrator   ~0049821

and r25189 for 1.3.x files, .. at least in 1.7.x

Issue History

Date Modified Username Field Change
2022-11-24 07:19 william New Issue
2022-11-24 07:19 william File Added: scribus17p3-scribus150format-qstringview-20221124-071340.patch
2022-11-24 15:36 ale Note Added: 0049817
2022-11-24 17:54 william Note Added: 0049818
2022-11-24 20:31 ale Note Added: 0049819
2022-11-24 20:46 cbradney Note Added: 0049820
2022-11-24 21:13 cbradney Note Added: 0049821
2022-11-25 17:02 jghali Summary [patch] scribus crashes opening sla files => Scribus crashes opening sla files
2022-11-25 17:02 jghali Assigned To => cbradney
2022-11-25 17:02 jghali Status new => resolved
2022-11-25 17:02 jghali Resolution open => fixed
2022-11-25 17:02 jghali Fixed in Version => 1.7.0.svn