I have an application developed with Qt 4.8.4 for VC2008. Application can be extended with plug-ins. I know these:
QPluginLoader checks that a plugin is linked against the same version of Qt as the application.
Plugins linked with a Qt library that has a higher version number will not be loaded by a library with a lower version number.
Plugins linked with a Qt library that has a lower major version number will not be loaded by a library with a higher major version number.
Also I know plugins are built using a Build Key [qt-project.org]
I have not yet tested, but I think Qt 4.8.4 in release configuration will produce binary compatible code between VC2008, VC2010, VC2012 (… and MinGW ?). Also I think this assumption is valid for different versions of GCC compiler.
Now the problem is: let’s say in interface class I have something like this
QWidget* createWidget(QWidget* parent) = 0
Plug-ins must implement this functions, with something like this
QWidget* createWidget(QWidget* parent)
{
return new QWidget(parent);
}
Now when parent will be destroyed, plug-in’s widget will be deleted with operator delete from VC2008. But if plug-in is developed with VC2010 the widget will be created with operator new from VC2010. From what I know this leads to memory corruption.
Other solution would be to add other function in interface class
void destroyWidget(QWidget* widget) = 0
Now plug-ins must implement this function and widget will be destroyed with operator delete with which it was implemented. But this “hack” require more functions in interface class.
So … what do you think ? Which one would be the best solution in your opinion ?
↧