mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Improve exception handling
- Do at least very basic handling in QtConcurrent run functions - Do not show a message box when not running in main thread
This commit is contained in:
parent
2575dca4b5
commit
f9d9c2a43c
@ -244,15 +244,21 @@ bool QgsApplication::notify( QObject * receiver, QEvent * event )
|
||||
}
|
||||
catch ( QgsException & e )
|
||||
{
|
||||
QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
|
||||
QgsDebugMsg( "Caught unhandled QgsException: " + e.what() );
|
||||
if ( qApp->thread() == QThread::currentThread() )
|
||||
QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
|
||||
}
|
||||
catch ( std::exception & e )
|
||||
{
|
||||
QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
|
||||
QgsDebugMsg( "Caught unhandled std::exception: " + QString::fromAscii( e.what() ) );
|
||||
if ( qApp->thread() == QThread::currentThread() )
|
||||
QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
QMessageBox::critical( activeWindow(), tr( "Exception" ), tr( "unknown exception" ) );
|
||||
QgsDebugMsg( "Caught unhandled unknown exception" );
|
||||
if ( qApp->thread() == QThread::currentThread() )
|
||||
QMessageBox::critical( activeWindow(), tr( "Exception" ), tr( "unknown exception" ) );
|
||||
}
|
||||
|
||||
return done;
|
||||
|
@ -187,7 +187,22 @@ void QgsMapRendererCustomPainterJob::futureFinished()
|
||||
|
||||
void QgsMapRendererCustomPainterJob::staticRender( QgsMapRendererCustomPainterJob* self )
|
||||
{
|
||||
self->doRender();
|
||||
try
|
||||
{
|
||||
self->doRender();
|
||||
}
|
||||
catch ( QgsException & e )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled QgsException: " + e.what() );
|
||||
}
|
||||
catch ( std::exception & e )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled std::exception: " + QString::fromAscii( e.what() ) );
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled unknown exception" );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapRendererCustomPainterJob::doRender()
|
||||
|
@ -207,7 +207,24 @@ void QgsMapRendererParallelJob::renderLayerStatic( LayerRenderJob& job )
|
||||
QTime t;
|
||||
t.start();
|
||||
QgsDebugMsg( QString( "job %1 start" ).arg(( ulong ) &job, 0, 16 ) );
|
||||
job.renderer->render();
|
||||
|
||||
try
|
||||
{
|
||||
job.renderer->render();
|
||||
}
|
||||
catch ( QgsException & e )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled QgsException: " + e.what() );
|
||||
}
|
||||
catch ( std::exception & e )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled std::exception: " + QString::fromAscii( e.what() ) );
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled unknown exception" );
|
||||
}
|
||||
|
||||
int tt = t.elapsed();
|
||||
QgsDebugMsg( QString( "job %1 end [%2 ms]" ).arg(( ulong ) &job, 0, 16 ).arg( tt ) );
|
||||
Q_UNUSED( tt );
|
||||
@ -218,7 +235,22 @@ void QgsMapRendererParallelJob::renderLabelsStatic( QgsMapRendererParallelJob* s
|
||||
{
|
||||
QPainter painter( &self->mFinalImage );
|
||||
|
||||
drawLabeling( self->mSettings, self->mLabelingRenderContext, self->mLabelingEngine, &painter );
|
||||
try
|
||||
{
|
||||
drawLabeling( self->mSettings, self->mLabelingRenderContext, self->mLabelingEngine, &painter );
|
||||
}
|
||||
catch ( QgsException & e )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled QgsException: " + e.what() );
|
||||
}
|
||||
catch ( std::exception & e )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled std::exception: " + QString::fromAscii( e.what() ) );
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
QgsDebugMsg( "Caught unhandled unknown exception" );
|
||||
}
|
||||
|
||||
painter.end();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user