PDA

View Full Version : QLibrary load inside class



^NyAw^
13th February 2012, 15:13
Hi,

I'm trying to load a library in runtime using QLibrary.
I'm using the QLibrary class inside a class. I'm able to call a resolved function from the library. The problem is on the next function,method, ... call. This call produces a "buffer saturation" error. If I load the library into the main it works perfectly.
I want to use the QLibrary inside a class because it will be like a plugin.

Is there any memory limitation or maybe I'm making a mistake?

Here there is the piece of code in the application constructor:


QLibrary myLib("pci-dask");
typedef I16 (*MyPrototype)(U16,U16);
MyPrototype myFunction = (MyPrototype) myLib.resolve("Register_Card");
myFunction = (MyPrototype) myLib.resolve("Register_Card");
if (myFunction)
card = myFunction(PCI_7230,card_number);

m_qDAQThread.setCard(card); //This cause the crash. Changing it to any call like a "QObject::connect" produces the same error


If I don't call "card = myFunction(PCI_7230,card_number)", there is no problem.

Thanks,

P.S.: I'm using Qt 4.6.1 and Visual Studio 2008 on Windows XP

^NyAw^
13th February 2012, 18:55
Hi,

Has no one found a similar problem?

Thanks,

^NyAw^
14th February 2012, 09:43
Hi,

There is an option in Visual Studio "/GS" that if I disable it then I get a "0xC0000005" error.
The problem is that I there is no crash if I don't call any resolved fucntion.


m_qLibrary.setFileName("pci-dask");
if (m_qLibrary.load())
{
//Pointer to functions
Register_Card = (pf_Register_Card) m_qLibrary.resolve("Register_Card");
Release_Card = (pf_Release_Card) m_qLibrary.resolve("Release_Card");
DI_ReadPort = (pf_DI_ReadPort) m_qLibrary.resolve("DI_ReadPort");
if (Register_Card)
m_card = Register_Card(PCI_7230,card_number);

QObject::connect(this,SIGNAL(mySignal()),this,SLOT (mySlot())); //This produces the error

if (DI_ReadPort)
I16 error = DI_ReadPort(m_card,0,&m_uInputs);
}

This produces the error: Excepción no controlada en 0x671d4836 (QtCored4.dll) en ADLINK_IO.exe: 0xC0000005: Infracción de acceso al leer la ubicación 0x6f6c7331.
That will be like "Exception not controlled in 0x671d4836 (QtCored4.dll) in ADLINK_IO.exe: 0xC0000005: error on reading 0x6f6c7331."

Thanks,