Skip to content

Commit

Permalink
Catch geos exception in event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 29, 2017
1 parent 6aeb9b7 commit a71132a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 39 deletions.
34 changes: 3 additions & 31 deletions src/core/geometry/qgsgeos.h
Expand Up @@ -250,42 +250,14 @@ class CORE_EXPORT QgsGeos: public QgsGeometryEngine

/// @cond PRIVATE

class GEOSException // clazy:exclude=rule-of-three

class GEOSException : public std::runtime_error
{
public:
explicit GEOSException( const QString &message )
: std::runtime_error( message.toUtf8().constData() )
{
if ( message == QLatin1String( "Unknown exception thrown" ) && lastMsg().isNull() )
{
msg = message;
}
else
{
msg = message;
lastMsg() = msg;
}
}

// copy constructor
GEOSException( const GEOSException &rhs )
{
*this = rhs;
}

~GEOSException()
{
if ( lastMsg() == msg )
lastMsg() = QString::null;
}

QString what()
{
return msg;
}

private:
QString msg;
static QString &lastMsg() { static QString sLastMsg; return sLastMsg; }
};

/// @endcond
Expand Down
7 changes: 0 additions & 7 deletions src/core/qgsapplication.cpp
Expand Up @@ -37,7 +37,6 @@
#include "qgsmessagelog.h"
#include "qgsannotationregistry.h"
#include "qgssettings.h"
#include "qgsgeos.h"

#include "gps/qgsgpsconnectionregistry.h"
#include "processing/qgsprocessingregistry.h"
Expand Down Expand Up @@ -314,12 +313,6 @@ bool QgsApplication::notify( QObject *receiver, QEvent *event )
if ( qApp->thread() == QThread::currentThread() )
QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
}
catch ( GEOSException &e )
{
QgsDebugMsg( "Caught unhandled GEOSException: " + e.what() );
if ( qApp->thread() == QThread::currentThread() )
QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
}
catch ( std::exception &e )
{
QgsDebugMsg( "Caught unhandled std::exception: " + QString::fromAscii( e.what() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgstracer.cpp
Expand Up @@ -550,7 +550,7 @@ bool QgsTracer::initGraph()

mHasTopologyProblem = true;

QgsDebugMsg( "Tracer Noding Exception: " + e.what() );
QgsDebugMsg( QString( "Tracer Noding Exception: %1" ).arg( e.what() ) );
}
#endif

Expand Down

0 comments on commit a71132a

Please sign in to comment.