r17241 by jghali - #10537 : crash when fixing multiple errors during PDF Pre-Flight verifier

scribus-commit scribus-commit at lists.scribus.net
Wed Jan 25 22:59:43 UTC 2012


Author: jghali
Date: Wed Jan 25 22:59:42 2012
New Revision: 17241

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17241
Log:
#10537 : crash when fixing multiple errors during PDF Pre-Flight verifier

Modified:
    trunk/Scribus/scribus/ui/checkDocument.cpp
    trunk/Scribus/scribus/ui/checkDocument.h

Modified: trunk/Scribus/scribus/ui/checkDocument.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17241&path=/trunk/Scribus/scribus/ui/checkDocument.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/checkDocument.cpp (original)
+++ trunk/Scribus/scribus/ui/checkDocument.cpp Wed Jan 25 22:59:42 2012
@@ -109,6 +109,9 @@
 {
 	if (itemMap.contains(ite))
 	{
+		// #10537 Check item has not been destroyed before requesting its selection
+		if (itemMap[ite].isNull())
+			return;
 		ScCore->primaryMainWindow()->closeActiveWindowMasterPageEditor();
 		if (itemMap[ite]->isTextFrame())
 			emit selectElement(itemMap[ite], true, posMap[ite]);
@@ -118,17 +121,30 @@
 	}
 	if (pageMap.contains(ite))
 	{
+		// #10537 Get page index from pointer in case user has deleted a page
+		// after preflight has been run
+		int pageIndex = m_Doc->DocPages.indexOf(pageMap[ite]);
+		if (pageIndex < 0)
+			return;
 		ScCore->primaryMainWindow()->closeActiveWindowMasterPageEditor();
-		emit selectPage(pageMap[ite]);
+		emit selectPage(pageIndex);
 		return;
 	}
 	if (masterPageMap.contains(ite))
 	{
-		emit selectMasterPage(masterPageMap[ite]);
+		// #10537 Get page index from pointer in case user has deleted a page
+		// after preflight has been run
+		int pageIndex = m_Doc->MasterPages.indexOf(masterPageMap[ite]);
+		if (pageIndex < 0)
+			return;
+		emit selectMasterPage(masterPageMap[ite]->pageName());
 		return;
 	}
 	if (masterPageItemMap.contains(ite))
 	{
+		// #10537 Check item has not been destroyed before requesting its selection
+		if (masterPageItemMap[ite].isNull())
+			return;
 		if (!m_Doc->masterPageMode())
 			emit selectMasterPage(masterPageItemMap[ite]->OnMasterPage);
 		if (itemMap[ite]->isTextFrame())
@@ -380,7 +396,7 @@
 			if (showPagesWithoutErrors)
 			{
 				page = new QTreeWidgetItem( masterPageRootItem);
-				masterPageMap.insert(page, doc->MasterPages.at(mPage)->pageName());
+				masterPageMap.insert(page, doc->MasterPages.at(mPage));
 			}
 // 			pagep = page;
 			QMap<PageItem*, errorCodes>::Iterator masterItemErrorsIt;
@@ -398,7 +414,7 @@
 					if (!showPagesWithoutErrors && page==NULL)
 					{
 						page = new QTreeWidgetItem( masterPageRootItem);
-						masterPageMap.insert(page, doc->MasterPages.at(mPage)->pageName());
+						masterPageMap.insert(page, doc->MasterPages.at(mPage));
 					}
 					hasError = true;
 					QTreeWidgetItem * object = new QTreeWidgetItem( page);
@@ -458,7 +474,7 @@
 			if (showPagesWithoutErrors)
 			{
 				page = new QTreeWidgetItem( reportDisplay);
-				pageMap.insert(page, aPage);
+				pageMap.insert(page, doc->DocPages.at(aPage));
 			}
 // 			pagep = page;
 			QMap<PageItem*, errorCodes>::Iterator docItemErrorsIt;
@@ -474,7 +490,7 @@
 					if (!showPagesWithoutErrors && page==NULL)
 					{
 						page = new QTreeWidgetItem( reportDisplay);
-						pageMap.insert(page, aPage);
+						pageMap.insert(page, doc->DocPages.at(aPage));
 					}
 					hasError = true;
 					itemError = false;

Modified: trunk/Scribus/scribus/ui/checkDocument.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17241&path=/trunk/Scribus/scribus/ui/checkDocument.h
==============================================================================
--- trunk/Scribus/scribus/ui/checkDocument.h (original)
+++ trunk/Scribus/scribus/ui/checkDocument.h Wed Jan 25 22:59:42 2012
@@ -8,6 +8,7 @@
 #define CHECKDOCUMENT_H
 
 #include <QMap>
+#include <QPointer>
 
 class QEvent;
 class QHBoxLayout;
@@ -18,12 +19,14 @@
 class QVBoxLayout;
 
 #include "scribusapi.h"
+
+#include "pageitem.h"
+#include "scribusstructs.h"
 #include "ui/scrpalettebase.h"
-#include "scribusstructs.h"
 
 class ScribusDoc;
 class ScComboBox;
-
+class ScPage;
 
 /*! \brief Preflight Verifier GUI (P.V.)
 A tool to check document for errors (in P.V. profiles)
@@ -101,13 +104,13 @@
 	QHBoxLayout* layout1;
 	QHBoxLayout* layout2;
 	//! \brief Mappping Page Item - item nr.
-	QMap<QTreeWidgetItem*, PageItem*> itemMap;
+	QMap<QTreeWidgetItem*, QPointer<PageItem> > itemMap;
 	//! \brief Mappping Page - page nr.
-	QMap<QTreeWidgetItem*, int> pageMap;
+	QMap<QTreeWidgetItem*, ScPage*> pageMap;
 	//! \brief Mappping Master Page - MP nr.
-	QMap<QTreeWidgetItem*, QString> masterPageMap;
+	QMap<QTreeWidgetItem*, ScPage*> masterPageMap;
 	//! \brief Mappping MP Item - MP item nr.
-	QMap<QTreeWidgetItem*, PageItem*> masterPageItemMap;
+	QMap<QTreeWidgetItem*, QPointer<PageItem> > masterPageItemMap;
 	//! \brief Mappping Page Item - cursor position in item
 	QMap<QTreeWidgetItem*, int> posMap;
 




More information about the scribus-commit mailing list