Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch geos exception in main event loop #4309

Merged
merged 2 commits into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 3 additions & 31 deletions src/core/geometry/qgsgeos.h
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion src/core/qgstracer.cpp
Original file line number Diff line number Diff line change
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