r24737 by jghali - #16656: Crash when importing pdf with the option as text

scribus-commit scribus-commit at lists.scribus.net
Wed Oct 6 19:21:31 UTC 2021


Author: jghali
Date: Wed Oct  6 19:21:31 2021
New Revision: 24737

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24737
Log:
#16656: Crash when importing pdf with the option as text

Modified:
    trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp

Modified: trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24737&path=/trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp	Wed Oct  6 19:21:31 2021
@@ -634,12 +634,13 @@
 
 void PdfTextOutputDev::endTextObject(GfxState* state)
 {
-	if (!m_pdfTextRecognition.activePdfTextRegion->pdfTextRegionLines.empty())
+	auto* activePdfTextRegion = m_pdfTextRecognition.activePdfTextRegion;
+	if (!activePdfTextRegion->pdfTextRegionLines.empty() && activePdfTextRegion->glyphs.size() > 0)
 	{
 		// Add the last glyph to the textregion
-		QPointF glyphXY = m_pdfTextRecognition.activePdfTextRegion->lastXY;
-		m_pdfTextRecognition.activePdfTextRegion->lastXY.setX(m_pdfTextRecognition.activePdfTextRegion->lastXY.x() - m_pdfTextRecognition.activePdfTextRegion->glyphs.back().dx);
-		if (m_pdfTextRecognition.activePdfTextRegion->addGlyphAtPoint(glyphXY, m_pdfTextRecognition.activePdfTextRegion->glyphs.back()) == PdfTextRegion::LineType::FAIL)
+		QPointF glyphXY = activePdfTextRegion->lastXY;
+		activePdfTextRegion->lastXY.setX(activePdfTextRegion->lastXY.x() - activePdfTextRegion->glyphs.back().dx);
+		if (activePdfTextRegion->addGlyphAtPoint(glyphXY, activePdfTextRegion->glyphs.back()) == PdfTextRegion::LineType::FAIL)
 		{
 			qDebug("FIXME: Rogue glyph detected, this should never happen because the cursor should move before glyphs in new regions are added.");
 		}
@@ -648,7 +649,7 @@
 #endif
 		renderTextFrame();
 	}
-	else if (!m_pdfTextRecognition.activePdfTextRegion->pdfTextRegionLines.empty())
+	else if (!activePdfTextRegion->pdfTextRegionLines.empty())
 		qDebug("FIXME:Rogue textblock");
 
 	m_pdfTextRecognition.setCharMode(PdfTextRecognition::AddCharMode::ADDFIRSTCHAR);




More information about the scribus-commit mailing list