[qet] [4543] Fix crash when open Qet with a .qet file has argument

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4543
Author:   blacksun
Date:     2016-06-06 21:07:13 +0200 (Mon, 06 Jun 2016)
Log Message:
-----------
Fix crash when open Qet with a .qet file has argument

Modified Paths:
--------------
    trunk/sources/ElementsCollection/elementscollectionwidget.cpp
    trunk/sources/ElementsCollection/elementscollectionwidget.h

Modified: trunk/sources/ElementsCollection/elementscollectionwidget.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.cpp	2016-06-06 18:34:34 UTC (rev 4542)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.cpp	2016-06-06 19:07:13 UTC (rev 4543)
@@ -70,11 +70,15 @@
  * @param project
  */
 void ElementsCollectionWidget::addProject(QETProject *project) {
-	m_model->addProject(project);
+	if (m_model)
+		m_model->addProject(project);
+	else
+		m_waiting_project.append(project);
 }
 
 void ElementsCollectionWidget::removeProject(QETProject *project) {
-	m_model->removeProject(project);
+	if (m_model)
+		m_model->removeProject(project);
 }
 
 bool ElementsCollectionWidget::event(QEvent *event)
@@ -443,6 +447,12 @@
 	new_model->addCommonCollection(false);
 	new_model->addCustomCollection(false);
 
+	if (!m_waiting_project.isEmpty()) {
+		foreach(QETProject *prj, m_waiting_project)
+			new_model->addProject(prj, false);
+		m_waiting_project.clear();
+	}
+
 	if (m_model)
 		foreach (QETProject *project, m_model->project())
 			new_model->addProject(project, false);

Modified: trunk/sources/ElementsCollection/elementscollectionwidget.h
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.h	2016-06-06 18:34:34 UTC (rev 4542)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.h	2016-06-06 19:07:13 UTC (rev 4543)
@@ -97,6 +97,7 @@
 				*m_show_all_dir;
 
 		bool m_first_show = true;
+		QList<QETProject *> m_waiting_project;
 };
 
 #endif // ELEMENTSCOLLECTIONWIDGET_H


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/