Answer the question
In order to leave comments, you need to log in
How to catch exceptions in QThread?
It is required to catch system exceptions outside the main thread. In the main thread, everything is very simple:
Redefine QApplication::notify() and rejoice:
bool notify(QObject *obj, QEvent *ev)
{
bool result = false;
try{
result = QApplication::notify(obj, ev);
} catch(...){
qDebug() << "exception";
result = false;
}
return result;
}
void MainWindow::on_pb1_clicked()
{
QObject* obj = (QObject*) 0x00112233;
delete obj;
}
void MainWindow::on_pb1_clicked()
{
QPluginLoader pluginLoader("d:/Sources/qt/_BUILDS/Plugin/Desktop_Qt_5_5_1_MSVC2013_64bit/release/FirstPlugin.dll");
QObject *pluginObj = pluginLoader.instance();
if (pluginObj){
CensorPluginRootInstance* root = qobject_cast<CensorPluginRootInstance *>(pluginObj);
if (root) {
PluginInterface* plugin = root->createPluginObject();
if (plugin){
ui->teStat->append("plugin load ok!");
QThread* thread = new QThread;
connect(thread, &QThread::started, plugin, &PluginInterface::Work);
plugin->moveToThread(thread);
thread->start();
} else
ui->teStat->append("plugin not loaded 3!");
}else
ui->teStat->append("plugin not loaded 2!");
}else
ui->teStat->append("plugin not loaded 1!");
}
bool Plugin::Work()
{
char* pc = (char*)0x00112233;
delete pc;
return false;
}
Answer the question
In order to leave comments, you need to log in
Pass your function, inside it already call the plugin with interception,
Movetothread, what is it?
Still there is a debugger, symbols.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question