Skip to content

Commit 3dedb15

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/branches/Release-0_8_0@7019 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fd47af0 commit 3dedb15

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/gui/qgisapp.cpp

+27-17
Original file line numberDiff line numberDiff line change
@@ -2660,7 +2660,7 @@ void QgisApp::fileOpen()
26602660
{
26612661
QMessageBox::critical(this,
26622662
tr("QGIS Project Read Error"),
2663-
tr("") + "\n" + e.what() );
2663+
tr("") + "\n" + QString::fromLocal8Bit( e.what() ) );
26642664
qDebug( "%s:%d %d bad layers found", __FILE__, __LINE__, e.layers().size() );
26652665

26662666
// attempt to find the new locations for missing layers
@@ -2671,7 +2671,7 @@ void QgisApp::fileOpen()
26712671
{
26722672
QMessageBox::critical(this,
26732673
tr("QGIS Project Read Error"),
2674-
tr("") + "\n" + e.what() );
2674+
tr("") + "\n" + QString::fromLocal8Bit( e.what() ) );
26752675
qDebug( "%s:%d BAD LAYERS FOUND", __FILE__, __LINE__ );
26762676
}
26772677
}
@@ -2742,7 +2742,7 @@ bool QgisApp::addProject(QString projectFile)
27422742

27432743
if ( QMessageBox::Yes == QMessageBox::critical( this,
27442744
tr("QGIS Project Read Error"),
2745-
tr("") + "\n" + e.what() + "\n" +
2745+
tr("") + "\n" + QString::fromLocal8Bit( e.what() ) + "\n" +
27462746
tr("Try to find missing layers?"),
27472747
QMessageBox::Yes | QMessageBox::Default,
27482748
QMessageBox::No | QMessageBox::Escape ) )
@@ -2760,7 +2760,7 @@ bool QgisApp::addProject(QString projectFile)
27602760
qDebug( "%s:%d BAD LAYERS FOUND", __FILE__, __LINE__ );
27612761

27622762
QMessageBox::critical( 0x0,
2763-
tr("Unable to open project"), QString::fromLocal8Bit(e.what()), QMessageBox::Ok,
2763+
tr("Unable to open project"), QString::fromLocal8Bit( e.what() ), QMessageBox::Ok,
27642764
Qt::NoButton );
27652765

27662766
mMapCanvas->freeze(false);
@@ -2855,7 +2855,7 @@ bool QgisApp::fileSave()
28552855
{
28562856
QMessageBox::critical( 0x0,
28572857
tr("Unable to save project ") + QgsProject::instance()->filename(),
2858-
e.what(),
2858+
QString::fromLocal8Bit( e.what() ),
28592859
QMessageBox::Ok,
28602860
Qt::NoButton );
28612861

@@ -2912,21 +2912,31 @@ void QgisApp::fileSaveAs()
29122912
fullPath.setFile( newFilePath );
29132913
}
29142914

2915-
2916-
QgsProject::instance()->filename( fullPath.filePath() );
2917-
2918-
if ( QgsProject::instance()->write() )
2915+
try
29192916
{
2920-
setTitleBarText_(*this); // update title bar
2921-
statusBar()->message(tr("Saved project to:") + " " + QgsProject::instance()->filename() );
2922-
// add this to the list of recently used project files
2923-
saveRecentProjectPath(fullPath.filePath(), settings);
2917+
QgsProject::instance()->filename( fullPath.filePath() );
2918+
2919+
if ( QgsProject::instance()->write() )
2920+
{
2921+
setTitleBarText_(*this); // update title bar
2922+
statusBar()->message(tr("Saved project to:") + " " + QgsProject::instance()->filename() );
2923+
// add this to the list of recently used project files
2924+
saveRecentProjectPath(fullPath.filePath(), settings);
2925+
}
2926+
else
2927+
{
2928+
QMessageBox::critical(this,
2929+
tr("Unable to save project"),
2930+
tr("Unable to save project to ") + QgsProject::instance()->filename() );
2931+
}
29242932
}
2925-
else
2933+
catch ( std::exception & e )
29262934
{
2927-
QMessageBox::critical(this,
2928-
tr("Unable to save project"),
2929-
tr("Unable to save project to ") + QgsProject::instance()->filename() );
2935+
QMessageBox::critical( 0x0,
2936+
tr("Unable to save project ") + QgsProject::instance()->filename(),
2937+
QString::fromLocal8Bit( e.what() ),
2938+
QMessageBox::Ok,
2939+
Qt::NoButton );
29302940
}
29312941
} // QgisApp::fileSaveAs
29322942

src/gui/qgsproject.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ bool QgsProject::read()
10161016
imp_->file.close(); // even though we got an error, let's make
10171017
// sure it's closed anyway
10181018

1019-
throw QgsIOException("Unable to open " + imp_->file.name());
1019+
throw QgsIOException( QObject::tr("Unable to open ") + imp_->file.name());
10201020

10211021
return false; // XXX raise exception? Ok now superfluous
10221022
// XXX because of exception.
@@ -1137,7 +1137,7 @@ bool QgsProject::read()
11371137
// doesn't *have* layers -- nor a GUI for that matter -- we'll just
11381138
// leave in the whining and boldly stomp on.
11391139

1140-
throw QgsException("Cannot get extents from " + imp_->file.name());
1140+
throw QgsException( QObject::tr("Cannot get extents from ") + imp_->file.name());
11411141

11421142
// return false;
11431143
}

0 commit comments

Comments
 (0)