Skip to content

Commit 12e2162

Browse files
author
timlinux
committed
Applied patch #725 which also fixes ticket #698
(This patch fixes crash (ticket #698) and also adds some i18n stuff (missing tr(), and encoding conversation where nedded). Included patches for HEAD and also for 0.8.x) git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7018 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 97ced05 commit 12e2162

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

src/app/qgisapp.cpp

+27-17
Original file line numberDiff line numberDiff line change
@@ -2729,7 +2729,7 @@ void QgisApp::fileOpen()
27292729
{
27302730
QMessageBox::critical(this,
27312731
tr("QGIS Project Read Error"),
2732-
tr("") + "\n" + e.what() );
2732+
tr("") + "\n" + QString::fromLocal8Bit( e.what() ) );
27332733
qDebug( "%s:%d %d bad layers found", __FILE__, __LINE__, static_cast<int>(e.layers().size()) );
27342734

27352735
// attempt to find the new locations for missing layers
@@ -2740,7 +2740,7 @@ void QgisApp::fileOpen()
27402740
{
27412741
QMessageBox::critical(this,
27422742
tr("QGIS Project Read Error"),
2743-
tr("") + "\n" + e.what() );
2743+
tr("") + "\n" + QString::fromLocal8Bit( e.what() ) );
27442744
qDebug( "%s:%d BAD LAYERS FOUND", __FILE__, __LINE__ );
27452745
}
27462746
}
@@ -2793,7 +2793,7 @@ bool QgisApp::addProject(QString projectFile)
27932793

27942794
if ( QMessageBox::Ok == QMessageBox::critical( this,
27952795
tr("QGIS Project Read Error"),
2796-
tr("") + "\n" + e.what() + "\n" +
2796+
tr("") + "\n" + QString::fromLocal8Bit( e.what() ) + "\n" +
27972797
tr("Try to find missing layers?"),
27982798
QMessageBox::Ok | QMessageBox::Cancel ) )
27992799
{
@@ -2810,7 +2810,7 @@ bool QgisApp::addProject(QString projectFile)
28102810
qDebug( "%s:%d BAD LAYERS FOUND", __FILE__, __LINE__ );
28112811

28122812
QMessageBox::critical( this,
2813-
tr("Unable to open project"), QString::fromLocal8Bit(e.what()) );
2813+
tr("Unable to open project"), QString::fromLocal8Bit( e.what() ) );
28142814

28152815
mMapCanvas->freeze(false);
28162816
mMapCanvas->refresh();
@@ -2898,7 +2898,7 @@ bool QgisApp::fileSave()
28982898
{
28992899
QMessageBox::critical( this,
29002900
tr("Unable to save project ") + QgsProject::instance()->filename(),
2901-
e.what() );
2901+
QString::fromLocal8Bit( e.what() ) );
29022902
}
29032903
return true;
29042904
} // QgisApp::fileSave
@@ -2949,21 +2949,31 @@ void QgisApp::fileSaveAs()
29492949
fullPath.setFile( newFilePath );
29502950
}
29512951

2952-
2953-
QgsProject::instance()->filename( fullPath.filePath() );
2954-
2955-
if ( QgsProject::instance()->write() )
2952+
try
29562953
{
2957-
setTitleBarText_(*this); // update title bar
2958-
statusBar()->message(tr("Saved project to:") + " " + QgsProject::instance()->filename() );
2959-
// add this to the list of recently used project files
2960-
saveRecentProjectPath(fullPath.filePath(), settings);
2954+
QgsProject::instance()->filename( fullPath.filePath() );
2955+
2956+
if ( QgsProject::instance()->write() )
2957+
{
2958+
setTitleBarText_(*this); // update title bar
2959+
statusBar()->message(tr("Saved project to:") + " " + QgsProject::instance()->filename() );
2960+
// add this to the list of recently used project files
2961+
saveRecentProjectPath(fullPath.filePath(), settings);
2962+
}
2963+
else
2964+
{
2965+
QMessageBox::critical(this,
2966+
tr("Unable to save project"),
2967+
tr("Unable to save project to ") + QgsProject::instance()->filename() );
2968+
}
29612969
}
2962-
else
2970+
catch ( std::exception & e )
29632971
{
2964-
QMessageBox::critical(this,
2965-
tr("Unable to save project"),
2966-
tr("Unable to save project to ") + QgsProject::instance()->filename() );
2972+
QMessageBox::critical( 0x0,
2973+
tr("Unable to save project ") + QgsProject::instance()->filename(),
2974+
QString::fromLocal8Bit( e.what() ),
2975+
QMessageBox::Ok,
2976+
Qt::NoButton );
29672977
}
29682978
} // QgisApp::fileSaveAs
29692979

0 commit comments

Comments
 (0)