[qet] qet/qet: [5383] Bugfix :

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


Revision: 5383
Author:   blacksun
Date:     2018-06-01 20:33:08 +0200 (Fri, 01 Jun 2018)
Log Message:
-----------
Bugfix :
1- When open a .qet by double click on it, QET ask user for open the backup file, of this .qet.
2- On windows, if user open a project from the recent files menu, when close QET the file is deleted :(  user lose her work

Modified Paths:
--------------
    trunk/sources/qetapp.cpp
    trunk/sources/qetproject.cpp

Modified: trunk/sources/qetapp.cpp
===================================================================
--- trunk/sources/qetapp.cpp	2018-05-26 21:54:03 UTC (rev 5382)
+++ trunk/sources/qetapp.cpp	2018-06-01 18:33:08 UTC (rev 5383)
@@ -150,10 +150,7 @@
 		QStringList extension_filter("*.qet");
 		QStringList list = dir.entryList(extension_filter);
 		for(QString str : list)
-		{
-			QFile file(dir.path() + "/" + str);
-			file.remove();
-		}
+			dir.remove(str);
 	}
 }
 
@@ -1644,6 +1641,15 @@
 	{
 		QStringList extension_filter("*.qet");
 		QStringList list = dir.entryList(extension_filter);
+		
+			//Remove from the list, the backup file of registred project
+		for(QETProject *project : registeredProjects().values())
+			if(!project->filePath().isEmpty())
+			{
+				QFileInfo info(project->filePath());
+				list.removeOne(info.fileName());
+			}
+		
 		if(list.isEmpty())
 			return;
 		

Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp	2018-05-26 21:54:03 UTC (rev 5382)
+++ trunk/sources/qetproject.cpp	2018-06-01 18:33:08 UTC (rev 5383)
@@ -166,12 +166,13 @@
 		//Project is closed without crash, we can safely remove the backup file.
 	if (!m_file_path.isEmpty())
 	{
-		QDir dir(QETApp::configDir() + "/backup");
+		QDir dir(QETApp::configDir() + "backup");
 		if(!dir.exists())
 			return;
 		
-		QString project_name = m_file_path.split("/").last();
-		dir.remove(project_name);
+		QFileInfo info(m_file_path);
+		if(info.exists())
+			dir.remove(info.fileName());
 	}
 }
 
@@ -1656,7 +1657,7 @@
 	if(m_file_path.isEmpty())
 		return;
 	
-	QDir dir(QETApp::configDir() + "/backup");
+	QDir dir(QETApp::configDir() + "backup");
 	if(!dir.exists())
 	{
 		dir.cdUp();
@@ -1664,11 +1665,13 @@
 		dir.cd("backup");
 	}
 	
-	QDomDocument xml_project;
-	xml_project.appendChild(xml_project.importNode(toXml().documentElement(), true));
-	
-	QString project_name = m_file_path.split("/").last();
-	QET::writeXmlFile(xml_project, dir.absoluteFilePath(project_name));
+	QFileInfo info(m_file_path);
+	if(info.exists())
+	{
+		QDomDocument xml_project;
+		xml_project.appendChild(xml_project.importNode(toXml().documentElement(), true));
+		QET::writeXmlFile(xml_project, dir.absoluteFilePath(info.fileName()));
+	}	
 }
 
 /**


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