Skip to content
Permalink
Browse files

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 1ae1e72f7c5b2f9d3c5a1cd94d572d8e502fdc0c
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/core/qgsopenclutils.cpp
@@ -18,6 +18,8 @@
#include "qgsmessagelog.h"
#include "qgslogger.h"

#include <QLibrary>

#include <QTextStream>
#include <QFile>
#include <QDebug>
@@ -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() );

0 comments on commit 1ae1e72

Please sign in to comment.
You can’t perform that action at this time.