Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check for libOpenCL.so at runtime
This should avoid a crash if the user
enables opencl and the library is not
found.
  • Loading branch information
elpaso committed Jan 25, 2019
1 parent 60f252c commit 1ae1e72
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/qgsopenclutils.cpp
Expand Up @@ -18,6 +18,8 @@
#include "qgsmessagelog.h"
#include "qgslogger.h"

#include <QLibrary>

#include <QTextStream>
#include <QFile>
#include <QDebug>
Expand Down Expand Up @@ -70,6 +72,15 @@ void QgsOpenClUtils::init()
static std::once_flag initialized;
std::call_once( initialized, [ = ]( )
{
QLibrary openCLLib{ QStringLiteral( "OpenCL" ) };
openCLLib.setLoadHints( QLibrary::LoadHint::ResolveAllSymbolsHint );
if ( ! openCLLib.load() )
{
QgsMessageLog::logMessage( QObject::tr( "Error loading OpenCL library: %1" )
.arg( openCLLib.errorString() ),
LOGMESSAGE_TAG, Qgis::Critical );
return;
}
try
{
activate( preferredDevice() );
Expand Down

0 comments on commit 1ae1e72

Please sign in to comment.