mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
QgsOpenClUtils::activate(): try to catch low-level Windows SEH to avoid hard crashes when OpenCL initialization fails
Tries to workaround #59617 Totally untested on my side. Might not be a good idea
This commit is contained in:
parent
81f0fc300b
commit
9b3ea776a2
@ -33,6 +33,11 @@
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <windows.h>
|
||||
#include <excpt.h>
|
||||
#endif
|
||||
|
||||
QLatin1String QgsOpenClUtils::SETTINGS_GLOBAL_ENABLED_KEY = QLatin1String( "OpenClEnabled" );
|
||||
QLatin1String QgsOpenClUtils::SETTINGS_DEFAULT_DEVICE_KEY = QLatin1String( "OpenClDefaultDevice" );
|
||||
QLatin1String QgsOpenClUtils::LOGMESSAGE_TAG = QLatin1String( "OpenCL" );
|
||||
@ -343,6 +348,11 @@ bool QgsOpenClUtils::activate( const QString &preferredDeviceId )
|
||||
sAvailable = true;
|
||||
return false;
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
// Try to capture hard crashes such as https://github.com/qgis/QGIS/issues/59617
|
||||
__try
|
||||
{
|
||||
#endif
|
||||
try
|
||||
{
|
||||
std::vector<cl::Platform> platforms;
|
||||
@ -455,6 +465,16 @@ bool QgsOpenClUtils::activate( const QString &preferredDeviceId )
|
||||
LOGMESSAGE_TAG, Qgis::MessageLevel::Warning );
|
||||
sAvailable = false;
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
}
|
||||
__except ( EXCEPTION_EXECUTE_HANDLER )
|
||||
{
|
||||
QgsMessageLog::logMessage( QObject::tr( "Unexpected exception of code %1 occurred while searching for OpenCL device. Note that the application may become unreliable and may need to be restarted." ).arg( GetExceptionCode() ),
|
||||
LOGMESSAGE_TAG, Qgis::MessageLevel::Warning );
|
||||
sAvailable = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return sAvailable;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user