From 198aef5df0b7406b79aaf9f79c548727b09b721c Mon Sep 17 00:00:00 2001 From: timlinux Date: Mon, 11 Jun 2007 03:32:57 +0000 Subject: [PATCH] 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@7018 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/app/qgisapp.cpp | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 26abd2cce66..0064a3eb050 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -2729,7 +2729,7 @@ void QgisApp::fileOpen() { QMessageBox::critical(this, tr("QGIS Project Read Error"), - tr("") + "\n" + e.what() ); + tr("") + "\n" + QString::fromLocal8Bit( e.what() ) ); qDebug( "%s:%d %d bad layers found", __FILE__, __LINE__, static_cast(e.layers().size()) ); // attempt to find the new locations for missing layers @@ -2740,7 +2740,7 @@ void QgisApp::fileOpen() { QMessageBox::critical(this, tr("QGIS Project Read Error"), - tr("") + "\n" + e.what() ); + tr("") + "\n" + QString::fromLocal8Bit( e.what() ) ); qDebug( "%s:%d BAD LAYERS FOUND", __FILE__, __LINE__ ); } } @@ -2793,7 +2793,7 @@ bool QgisApp::addProject(QString projectFile) if ( QMessageBox::Ok == QMessageBox::critical( this, tr("QGIS Project Read Error"), - tr("") + "\n" + e.what() + "\n" + + tr("") + "\n" + QString::fromLocal8Bit( e.what() ) + "\n" + tr("Try to find missing layers?"), QMessageBox::Ok | QMessageBox::Cancel ) ) { @@ -2810,7 +2810,7 @@ bool QgisApp::addProject(QString projectFile) qDebug( "%s:%d BAD LAYERS FOUND", __FILE__, __LINE__ ); QMessageBox::critical( this, - tr("Unable to open project"), QString::fromLocal8Bit(e.what()) ); + tr("Unable to open project"), QString::fromLocal8Bit( e.what() ) ); mMapCanvas->freeze(false); mMapCanvas->refresh(); @@ -2898,7 +2898,7 @@ bool QgisApp::fileSave() { QMessageBox::critical( this, tr("Unable to save project ") + QgsProject::instance()->filename(), - e.what() ); + QString::fromLocal8Bit( e.what() ) ); } return true; } // QgisApp::fileSave @@ -2949,21 +2949,31 @@ void QgisApp::fileSaveAs() fullPath.setFile( newFilePath ); } - - QgsProject::instance()->filename( fullPath.filePath() ); - - if ( QgsProject::instance()->write() ) + try { - setTitleBarText_(*this); // update title bar - statusBar()->message(tr("Saved project to:") + " " + QgsProject::instance()->filename() ); - // add this to the list of recently used project files - saveRecentProjectPath(fullPath.filePath(), settings); + QgsProject::instance()->filename( fullPath.filePath() ); + + if ( QgsProject::instance()->write() ) + { + setTitleBarText_(*this); // update title bar + statusBar()->message(tr("Saved project to:") + " " + QgsProject::instance()->filename() ); + // add this to the list of recently used project files + saveRecentProjectPath(fullPath.filePath(), settings); + } + else + { + QMessageBox::critical(this, + tr("Unable to save project"), + tr("Unable to save project to ") + QgsProject::instance()->filename() ); + } } - else + catch ( std::exception & e ) { - QMessageBox::critical(this, - tr("Unable to save project"), - tr("Unable to save project to ") + QgsProject::instance()->filename() ); + QMessageBox::critical( 0x0, + tr("Unable to save project ") + QgsProject::instance()->filename(), + QString::fromLocal8Bit( e.what() ), + QMessageBox::Ok, + Qt::NoButton ); } } // QgisApp::fileSaveAs