Skip to content

Commit 0a710fe

Browse files
author
g_j_m
committed
Warn if loading a project file from an older version of qgis (prompted
by ticket #314) git-svn-id: http://svn.osgeo.org/qgis/trunk@6028 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b3d8dd6 commit 0a710fe

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/gui/qgsproject.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ using namespace std;
3131
#include "qgsexception.h"
3232
#include "qgsprojectproperty.h"
3333
#include "qgsmapcanvas.h"
34+
#include "qgslogger.h"
3435

3536
#include <QApplication>
3637
#include <QFileInfo>
@@ -1084,7 +1085,30 @@ bool QgsProject::read()
10841085
QgsDebug( QString("project file has version " + fileVersion).ascii() );
10851086
}
10861087

1087-
// XXX some day insert version checking
1088+
QStringList fileVersionParts = fileVersion.split(".");
1089+
QStringList qgisVersionParts = QString(QGis::qgisVersion).split(".");
1090+
1091+
bool older = false;
1092+
1093+
if (fileVersionParts.size() != 3 || qgisVersionParts.size() != 3)
1094+
older = false; // probably an older version
1095+
else
1096+
{
1097+
if (fileVersionParts.at(0) < qgisVersionParts.at(0))
1098+
older = true;
1099+
else if (fileVersionParts.at(1) < qgisVersionParts.at(1))
1100+
older = true;
1101+
else if (fileVersionParts.at(2) < qgisVersionParts.at(2))
1102+
older = true;
1103+
}
1104+
1105+
if (older)
1106+
{
1107+
QgsLogger::warning("Loading a file that was saved with an older "
1108+
"version of qgis (saved in " + fileVersion +
1109+
", loaded in " + QGis::qgisVersion +
1110+
"). Problems may occur.");
1111+
}
10881112

10891113
#ifdef QGISDEBUG
10901114
qDebug(("Project title: " + imp_->title).toLocal8Bit().data());

0 commit comments

Comments
 (0)