Skip to content
Permalink
Browse files
Catch geos exception in event loop
  • Loading branch information
m-kuhn committed Mar 29, 2017
1 parent 6aeb9b7 commit a71132a15bb7a5be3ff8fbd73331bcf0d6b0aaa8
Showing with 4 additions and 39 deletions.
  1. +3 −31 src/core/geometry/qgsgeos.h
  2. +0 −7 src/core/qgsapplication.cpp
  3. +1 −1 src/core/qgstracer.cpp
@@ -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
@@ -37,7 +37,6 @@
#include "qgsmessagelog.h"
#include "qgsannotationregistry.h"
#include "qgssettings.h"
#include "qgsgeos.h"

#include "gps/qgsgpsconnectionregistry.h"
#include "processing/qgsprocessingregistry.h"
@@ -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() ) );
@@ -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

0 comments on commit a71132a

Please sign in to comment.