Skip to content

Commit

Permalink
Applied patch #725 which also fixes ticket #698
Browse files Browse the repository at this point in the history
(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
  • Loading branch information
timlinux committed Jun 11, 2007
1 parent fd47af0 commit 3dedb15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
44 changes: 27 additions & 17 deletions src/gui/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,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__, e.layers().size() );

// attempt to find the new locations for missing layers
Expand All @@ -2671,7 +2671,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__ );
}
}
Expand Down Expand Up @@ -2742,7 +2742,7 @@ bool QgisApp::addProject(QString projectFile)

if ( QMessageBox::Yes == 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::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape ) )
Expand All @@ -2760,7 +2760,7 @@ bool QgisApp::addProject(QString projectFile)
qDebug( "%s:%d BAD LAYERS FOUND", __FILE__, __LINE__ );

QMessageBox::critical( 0x0,
tr("Unable to open project"), QString::fromLocal8Bit(e.what()), QMessageBox::Ok,
tr("Unable to open project"), QString::fromLocal8Bit( e.what() ), QMessageBox::Ok,
Qt::NoButton );

mMapCanvas->freeze(false);
Expand Down Expand Up @@ -2855,7 +2855,7 @@ bool QgisApp::fileSave()
{
QMessageBox::critical( 0x0,
tr("Unable to save project ") + QgsProject::instance()->filename(),
e.what(),
QString::fromLocal8Bit( e.what() ),
QMessageBox::Ok,
Qt::NoButton );

Expand Down Expand Up @@ -2912,21 +2912,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

Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ bool QgsProject::read()
imp_->file.close(); // even though we got an error, let's make
// sure it's closed anyway

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

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

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

// return false;
}
Expand Down

0 comments on commit 3dedb15

Please sign in to comment.