r21458 by jghali - fix potential crash after importing PDF with broken annotations

scribus-commit scribus-commit at lists.scribus.net
Wed Oct 5 19:26:47 UTC 2016


Author: jghali
Date: Wed Oct  5 19:26:47 2016
New Revision: 21458

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21458
Log:
fix potential crash after importing PDF with broken annotations

Modified:
    trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
    trunk/Scribus/scribus/ui/annota.cpp

Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21458&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp	Wed Oct  5 19:26:47 2016
@@ -509,13 +509,13 @@
 		ite->AutoName = false;
 		if (act->getKind() == actionGoTo)
 		{
-			ite->annotation().setZiel(pagNum - 1);
+			ite->annotation().setZiel((pagNum > 0) ? (pagNum - 1) : (m_actPage - 1));
 			ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco));
 			ite->annotation().setActionType(2);
 		}
 		else if (act->getKind() == actionGoToR)
 		{
-			ite->annotation().setZiel(pagNum - 1);
+			ite->annotation().setZiel((pagNum > 0) ? (pagNum - 1) : (m_actPage - 1));
 			ite->annotation().setExtern(fileName);
 			ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco));
 			ite->annotation().setActionType(9);
@@ -935,7 +935,7 @@
 						pagNum = dst->getPageNum();
 					xco = dst->getLeft();
 					yco = dst->getTop();
-					ite->annotation().setZiel(pagNum - 1);
+					ite->annotation().setZiel((pagNum > 0) ? (pagNum - 1) : (m_actPage - 1));
 					ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco));
 					ite->annotation().setActionType(2);
 				}
@@ -959,7 +959,7 @@
 								pagNum = dstn->getPageNum();
 							xco = dstn->getLeft();
 							yco = dstn->getTop();
-							ite->annotation().setZiel(pagNum - 1);
+							ite->annotation().setZiel((pagNum > 0) ? (pagNum - 1) : (m_actPage - 1));
 							ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco));
 							ite->annotation().setActionType(2);
 						}
@@ -982,7 +982,7 @@
 					pagNum = dst->getPageNum();
 					xco = dst->getLeft();
 					yco = dst->getTop();
-					ite->annotation().setZiel(pagNum - 1);
+					ite->annotation().setZiel((pagNum > 0) ? (pagNum - 1) : (m_actPage - 1));
 					ite->annotation().setExtern(fileName);
 					ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco));
 					ite->annotation().setActionType(9);
@@ -1001,7 +1001,7 @@
 							pagNum = dstn->getPageNum();
 							xco = dstn->getLeft();
 							yco = dstn->getTop();
-							ite->annotation().setZiel(pagNum - 1);
+							ite->annotation().setZiel((pagNum > 0) ? (pagNum - 1) : (m_actPage - 1));
 							ite->annotation().setExtern(fileName);
 							ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco));
 							ite->annotation().setActionType(9);

Modified: trunk/Scribus/scribus/ui/annota.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21458&path=/trunk/Scribus/scribus/ui/annota.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/annota.cpp	(original)
+++ trunk/Scribus/scribus/ui/annota.cpp	Wed Oct  5 19:26:47 2016
@@ -178,7 +178,8 @@
 		Pg = new Navigator( GroupBox1, 100, item->annotation().Ziel()+1, view, item->annotation().Extern());
 	else
 	{
-		if (item->annotation().Ziel() < view->Doc->Pages->count())
+		int targetPage = item->annotation().Ziel();
+		if ((targetPage >= 0) && (targetPage < view->Doc->Pages->count()))
 			Pg = new Navigator( GroupBox1, 100, item->annotation().Ziel(), view);
 		else
 		{




More information about the scribus-commit mailing list