Well, I found out that some code executed after the call of the DLL function behaves differently than if the same code is executed before the DLL function call.
If I do something like:
...
GetInfo getInfo = (GetInfo) m_dll->resolve("GetInfo");
if (getInfo) {
str
= QString("%1 %2 %3 %4 %5 %6").
arg(1).
arg("aa").
arg(3).
arg("bb").
arg(5).
arg(6);
m_ui->setSoftwareVersion(str);
getInfo(m_interfaceNum, 0, tmp_version, tmp_feature, tmp_manufacturer,tmp_controller);
...
...
GetInfo getInfo = (GetInfo) m_dll->resolve("GetInfo");
if (getInfo) {
QString str;
str = QString("%1 %2 %3 %4 %5 %6").arg(1).arg("aa").arg(3).arg("bb").arg(5).arg(6);
m_ui->setSoftwareVersion(str);
getInfo(m_interfaceNum, 0, tmp_version, tmp_feature, tmp_manufacturer,tmp_controller);
...
To copy to clipboard, switch view to plain text mode
it will work...
... but if I do something like:
...
GetInfo getInfo = (GetInfo) m_dll->resolve("GetInfo");
if (getInfo) {
getInfo(m_interfaceNum, 0, tmp_version, tmp_feature, tmp_manufacturer,tmp_controller);
str
= QString("%1 %2 %3 %4 %5 %6").
arg(1).
arg("aa").
arg(3).
arg("bb").
arg(5).
arg(6);
m_ui->setSoftwareVersion(str);
...
...
GetInfo getInfo = (GetInfo) m_dll->resolve("GetInfo");
if (getInfo) {
QString str;
getInfo(m_interfaceNum, 0, tmp_version, tmp_feature, tmp_manufacturer,tmp_controller);
str = QString("%1 %2 %3 %4 %5 %6").arg(1).arg("aa").arg(3).arg("bb").arg(5).arg(6);
m_ui->setSoftwareVersion(str);
...
To copy to clipboard, switch view to plain text mode
it wont work. (str is filled differently and the line m->ui... brings QT to crash)
If you observe how str is filled in the second case, you will note that the last argument (6) is not filled in correctly. Also in the second case using a fix string in the line m_ui->setSoftwareVersion("my fixed string"); will also make the app to crash, while it does not if the same line is executed before the DLL function call.
I have attached a small project to demonstrate this issue.
The mentionned code is located in can_zcan4usbfx.cpp.
Please note that the DLL provided in my project can be dowloaded directly at http://www.zanthic.com/can4usbfx.htm
Do you have an idea what this could be ?
Bookmarks