Handling Exceptions Thrown by QPluginLoader :: load ()

I have 2 Qt plugins, main and auxiliary, with main.dlldownload helper.dll. I can successfully download main.dllusing QPluginLoaderwhen both main.dlland helper.dllare in the same folder. When helper.dllmissing and I try to load main.dll, an exception is thrown. This understandable reason was helper.dllnot found. My task is to successfully catch the thrown exception, and not the application crash. Although debugging here shows Qt Creator:

enter image description here

The following code does not solve the problem, so I need to do something else ...

std::exception_ptr eptr;
QPluginLoader pluginLoader(packagePath);
try
{
    pluginLoader.load();
}
catch(...)
{
    eptr = std::current_exception();
}
+4
source share
2 answers

. , Qt (-, Qt , Qt. script .pro Qt Creator. , , QPluginLoader::errrorString(), QPluginLoader::load() false.

:

QPluginLoader pluginLoader(m_packagePath);

bool bLoaded = pluginLoader.load();
if (bLoaded)
{
    QObject* plugin = pluginLoader.instance();
    m_metaObject = plugin->metaObject();
    if (m_metaObject == nullptr)
    {
        qCritical() << "Unable to obtain entry class of input plugin. Please check your plugin.";
        return false;
    }
}
else
{
    qCritical() << "Message from Qt plugin loader:";
    qCritical() << pluginLoader.errorString();
    qCritical() << "Please make sure your input Qt plugin along with its dependencies are deployed with winqtdeploy.exe and in the same folder as your plugin.";
    exit(-1);
}

script Stackoverflow, :

Qt Creator

0

, Windows __try/__except:

__try 
{
   // guarded code
}
__except ( expression )
{
   // exception handler code
}

SEH, MSDN : https://msdn.microsoft.com/en-us/library/swezty51.aspx


, , , SetUnhandledExceptionFilter.

+1

All Articles