r23802 by jghali - Avoid lots of "QList::insert(): Index out of range." warnings with Qt >= 5.15

scribus-commit scribus-commit at lists.scribus.net
Wed May 13 15:27:44 UTC 2020


Author: jghali
Date: Wed May 13 15:27:43 2020
New Revision: 23802

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23802
Log:
Avoid lots of "QList::insert(): Index out of range." warnings with Qt >= 5.15

Modified:
    trunk/Scribus/scribus/loadsaveplugin.cpp
    trunk/Scribus/scribus/loadsaveplugin.h

Modified: trunk/Scribus/scribus/loadsaveplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23802&path=/trunk/Scribus/scribus/loadsaveplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/loadsaveplugin.cpp	(original)
+++ trunk/Scribus/scribus/loadsaveplugin.cpp	Wed May 13 15:27:43 2020
@@ -19,11 +19,6 @@
 QList<FileFormat> LoadSavePlugin::formats;
 
 LoadSavePlugin::LoadSavePlugin() :
-	m_Doc(nullptr),
-	m_View(nullptr),
-	m_ScMW(nullptr),
-	m_mwProgressBar(nullptr),
-	m_AvailableFonts(nullptr),
 	undoManager(UndoManager::instance())
 {
 }
@@ -291,10 +286,8 @@
 	// If we don't find one, we insert before the end iterator, ie append.
 	if (fmt.formatId == 0) // only for custom plugins
 	{
-		uint id;
-		if (formats.isEmpty())
-			id = FORMATID_FIRSTUSER;
-		else
+		uint id = FORMATID_FIRSTUSER;
+		if (!formats.isEmpty())
 		{
 			QList<FileFormat>::iterator it(formats.begin());
 			QList<FileFormat>::iterator itEnd(formats.end());
@@ -305,12 +298,9 @@
 				++it;
 			}
 			id++;
-
-//			id = qMax(static_cast<int>(formats.last().formatId), FORMATID_FIRSTUSER-1);
-//			id++;
 		}
 		fmt.formatId = id;
-		formats.insert(id, fmt);
+		formats.append(fmt);
 	}
 	else
 	{
@@ -388,11 +378,11 @@
 
 void LoadSavePlugin::setupTargets(ScribusDoc *targetDoc, ScribusView* targetView, ScribusMainWindow* targetMW, QProgressBar* targetMWPRogressBar, SCFonts* targetAvailableFonts)
 {
-	m_Doc=targetDoc;
-	m_View=targetView;
-	m_ScMW=targetMW;
-	m_mwProgressBar=targetMWPRogressBar;
-	m_AvailableFonts=targetAvailableFonts;
+	m_Doc = targetDoc;
+	m_View = targetView;
+	m_ScMW = targetMW;
+	m_mwProgressBar = targetMWPRogressBar;
+	m_AvailableFonts = targetAvailableFonts;
 }
 
 void LoadSavePlugin::getReplacedFontData(bool & /*getNewReplacement*/, QMap<QString,QString> &/*getReplacedFonts*/, QList<ScFace> &/*getDummyScFaces*/)
@@ -471,26 +461,11 @@
 	return (plug && save) ? plug->saveElements(xp, yp, wp, hp, selection, prevData) : "";
 }
 
-FileFormat::FileFormat() :
-	formatId(0),
-	load(false),
-	save(false),
-	thumb(false),
-	colorReading(false),
-	nativeScribus(false),
-	priority(0),
-	plug(nullptr)
+FileFormat::FileFormat()
 {
 }
 
 FileFormat::FileFormat(LoadSavePlugin* plug) :
-	formatId(0),
-	load(false),
-	save(false),
-	thumb(false),
-	colorReading(false),
-	nativeScribus(false),
-	priority(0),
 	plug(plug)
 {
 }

Modified: trunk/Scribus/scribus/loadsaveplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23802&path=/trunk/Scribus/scribus/loadsaveplugin.h
==============================================================================
--- trunk/Scribus/scribus/loadsaveplugin.h	(original)
+++ trunk/Scribus/scribus/loadsaveplugin.h	Wed May 13 15:27:43 2020
@@ -136,13 +136,13 @@
 		// Set standard message for dom style errors with line and column
 		virtual void setDomParsingError(const QString& msg, int line, int column);
 
-		ScribusDoc*        m_Doc;
-		ScribusView*       m_View; //For 1.2.x loader at the moment
-		ScribusMainWindow* m_ScMW; //For plugins when required
-		QProgressBar*      m_mwProgressBar;
-		SCFonts*           m_AvailableFonts;
+		ScribusDoc*        m_Doc { nullptr };
+		ScribusView*       m_View { nullptr }; //For 1.2.x loader at the moment
+		ScribusMainWindow* m_ScMW { nullptr }; //For plugins when required
+		QProgressBar*      m_mwProgressBar { nullptr };
+		SCFonts*           m_AvailableFonts { nullptr };
 		QString            m_lastSavedFile;
-		UndoManager * const undoManager;
+		UndoManager * const undoManager { nullptr };
 
 	private:
 		// A list of all supported formats. This is maintained by plugins
@@ -225,7 +225,7 @@
 		// priorities to control what order they're tried in when a user
 		// tries to open a file).
 		// Note that dialog box options are sorted in descending `id' order.
-		uint formatId;
+		uint formatId { 0 };
 		// The human-readable, translated name of this file format.
 		QString trName;
 		// A filter in the format used by QFileDialog that should be used to
@@ -238,26 +238,25 @@
 		// Extension list supported by format
 		QStringList fileExtensions;
 		// Can we load it?
-		bool load;
+		bool load { false };
 		// Can we save it?
-		bool save;
+		bool save { false };
 		// Do we support thumbnails
-		bool thumb;
+		bool thumb { false };
 		// Can we load colors?
-		bool colorReading;
+		bool colorReading { false };
 		//Native Scribus format (for putting at the top of the file loader lists)
-		bool nativeScribus;
+		bool nativeScribus { false };
 		// Priority of this format from 0 (lowest, tried last) to
 		// 255 (highest, tried first). 64-128 recommended in general.
 		// Priority controls the order options are displayed in when a file
 		// of a given type is selected in a dialog, and controls the order
 		// loaders are tried in when multiple plugins support the same file
 		// type.
-		unsigned short int priority;
+		unsigned short int priority { 0 };
 		// For convenience, a pointer back to the plugin to use to open
 		// this format.
-		LoadSavePlugin * plug;
-//		LoadSavePlugin * const plug;
+		LoadSavePlugin * plug { nullptr };
 };
 
 




More information about the scribus-commit mailing list