Skip to content

Commit 7904178

Browse files
author
rblazek
committed
better error message
git-svn-id: http://svn.osgeo.org/qgis/trunk@5109 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3f6857d commit 7904178

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/plugins/grass/qgsgrassbrowser.cpp

+21-7
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ void QgsGrassBrowser::doubleClicked(const QModelIndex & index)
219219
addMap();
220220
}
221221

222+
QString QgsGrassBrowser::formatMessage( QString msg )
223+
{
224+
return msg.replace("<","&lt;").replace(">","&gt;").replace("\n","<br>");
225+
}
226+
222227
void QgsGrassBrowser::copyMap()
223228
{
224229
#ifdef QGISDEBUG
@@ -274,14 +279,17 @@ void QgsGrassBrowser::copyMap()
274279
module.append(".exe");
275280
#endif
276281
QProcess process(this);
277-
process.start(module, QStringList( typeName + "=" + map + "@" + mapset + "," + newName ) );
282+
QStringList args(typeName + "=" + map + "@" + mapset + "," + newName );
283+
process.start(module, args );
278284
if ( !process.waitForFinished() || process.exitCode() != 0 )
279285
{
280286
QString output ( process.readAllStandardOutput () );
281287
QString error ( process.readAllStandardError () );
282288
QMessageBox::warning( 0, "Warning", "Cannot copy map "
283-
+ map + "@" + mapset + "<br>" + output.replace("\n","<br>")
284-
+ "<br>" + error.replace("\n","<br>") );
289+
+ map + "@" + mapset
290+
+ "<br>command: " + module + " " + args.join(" ")
291+
+ "<br>" + formatMessage(output)
292+
+ "<br>" + formatMessage(error) );
285293
}
286294
else
287295
{
@@ -337,14 +345,17 @@ void QgsGrassBrowser::renameMap()
337345
module.append(".exe");
338346
#endif
339347
QProcess process(this);
348+
QStringList args(typeName + "=" + map + "," + newName );
340349
process.start(module, QStringList( typeName + "=" + map + "," + newName ) );
341350
if ( !process.waitForFinished() || process.exitCode() != 0 )
342351
{
343352
QString output ( process.readAllStandardOutput () );
344353
QString error ( process.readAllStandardError () );
345354
QMessageBox::warning( 0, "Warning", "Cannot rename map "
346-
+ map + "<br>" + output.replace("\n","<br>")
347-
+ "<br>" + error.replace("\n","<br>") );
355+
+ map
356+
+ "<br>command: " + module + " " + args.join(" ")
357+
+ "<br>" + formatMessage(output)
358+
+ "<br>" + formatMessage(error) );
348359
}
349360
else
350361
{
@@ -389,14 +400,17 @@ void QgsGrassBrowser::deleteMap()
389400
module.append(".exe");
390401
#endif
391402
QProcess process(this);
403+
QStringList args(typeName + "=" + map );
392404
process.start(module, QStringList( typeName + "=" + map ) );
393405
if ( !process.waitForFinished() || process.exitCode() != 0 )
394406
{
395407
QString output ( process.readAllStandardOutput () );
396408
QString error ( process.readAllStandardError () );
397409
QMessageBox::warning( 0, "Warning", "Cannot delete map "
398-
+ map + "<br>" + output.replace("\n","<br>")
399-
+ "<br>" + error.replace("\n","<br>") );
410+
+ map
411+
+ "<br>command: " + module + " " + args.join(" ")
412+
+ "<br>" + formatMessage(output)
413+
+ "<br>" + formatMessage(error) );
400414
}
401415
else
402416
{

src/plugins/grass/qgsgrassbrowser.h

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ public slots:
101101
QAction *mActionRenameMap;
102102
QAction *mActionSetRegion;
103103
QAction *mActionRefresh;
104+
105+
//! Escape HTML tags and convert \n to <br>
106+
QString formatMessage ( QString msg );
104107
};
105108

106109
#endif // QGSGRASSBROWSER_H

0 commit comments

Comments
 (0)