Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.12.12
-
None
Description
I have already read from https://bugreports.qt.io/browse/QTBUG-13505
The problem I encountered is quite different from 13505
I want to implement the plugin hot update function by using QFileSystemWatcher and QPluginLoader,like this:
{ m_pluginPath = "libtestplugin.so"; m_pfilewatcher = new QFileSystemWatcher(this); m_pfilewatcher->addPath(m_pluginPath); m_ploader = new QPluginLoader(m_pluginPath); m_ploader->setLoadHints(0); if(m_ploader->load()){ if(m_pinstance= m_ploader->instance()){ m_pabs = dynamic_cast<AbstractProcess *>(m_pinstance); m_pwgt = m_pabs->GetWidget(); } }else{ qDebug()<<m_ploader->errorString(); } m_pwgt->show(); this->setCentralWidget(m_pwgt); connect(m_pfilewatcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::slotfilechange); } void MainWindow::slotfilechange(const QString &path) { QTimer::singleShot(2000, this, [=](){ m_pfilewatcher->addPath(m_pluginPath); if(m_pinstance){ delete m_pinstance; m_pinstance = nullptr; } if (m_ploader) { bool flag = m_ploader->unload(); qDebug() << "unload result =" << flag; delete m_ploader; m_ploader = nullptr; m_pabs = nullptr; m_pwgt = nullptr; } m_ploader = new QPluginLoader(m_pluginPath); m_ploader->setLoadHints(0); if(m_ploader->load()){ if(m_pinstance = m_ploader->instance()){ m_pabs = dynamic_cast<AbstractProcess *>(m_pinstance); m_pwgt = m_pabs->GetWidget(); } }else{ qDebug()<<m_ploader->errorString(); } m_pwgt->show(); this->setCentralWidget(m_pwgt); }); }
Operation process
1. Start the main program and load the. so file
2. Delete the. so file
3. Copy a new. so file to the directory
4. Observation results
Can browse attachment videos, a success ,a fail (unload res is always true)
When the. so file is deleted and an unload is triggered, it is found that( use cat /proc/pid/maps | grep libdisplay.so)
7f8a92a000-7f8a931000 r-xp 00000000 103:05 7355231 libdisplay.so (deleted) , Always output this when it fails
It seems that libdisplay.so has not been completely uninstalled
I don't think it's a Qt issue, it should be a problem with the dynamic library code(Business code cannot be uploaded)
I deleted most of the business code and was able to achieve hot updates, but I couldn't find the root cause
I would like to ask, in this situation, which direction should I investigate the problem from? Thank you