PDA

View Full Version : Handling callbacks in Qt5



oela
8th January 2014, 15:20
Good day experts,

We have an IPC protocol stack that was developed a while ago, which I inherited. I am currently trying to use this stack in my Qt5 application to communicate with some of our other devices which use this IPC protocol stack. This stack is based on callbacks and due to its complex nature and my limited understanding thereof, I cannot easily convert it to Qt's signals and slots.

I have attached the header file that we use to make the callbacks and below is a typical example of how it is used:



_ripc_protocol_handler->register_platform_specific_send_function(
(Rap_send_callback) make_callback(
(Rap_send_callback*) 0, this,
&Tc4_lp_programmer::_write_to_port
)
);


with Rap_send_callback defined as follows:



typedef cntb_cb::Callback<Rap_callback_object*> Rap_send_callback;


This code works fine with Visual Studio 2005 C++ compiler. In Qt5 with the MingW compiler for Windows, I do not get any compiler warnings or errors, but at runtime the program would crash when registering the callback as illustrated above.

I am aware that I am providing limited information here, I'll do my best to gather some more, but can someone please just provide me with some pointers or just point me in the right direction?

Thanks in advance!

anda_skoa
8th January 2014, 15:38
This code works fine with Visual Studio 2005 C++ compiler. In Qt5 with the MingW compiler for Windows, I do not get any compiler warnings or errors, but at runtime the program would crash when registering the callback as illustrated above.

Just to clarify: do you have
a) a Qt5 application that when compiled with VS2005 works but does not work when compiled with MingW
or
b) a non-Qt applicaiton that works when compiled with VS2005 but does not when compiled MingW?

Cheers,
_

oela
8th January 2014, 19:44
It is actually just a pure C++ library which I incorporated in my new Qt5 application. I used the exact same code in a different Visual Studio 2005 app and it worked fine. The library is not Visual Studio specific because we use it with TI's C++ compiler for DSPs.

ChrisW67
8th January 2014, 21:53
This could be anything from a null pointer, through relying on compiler specific or undefined behaviour, to how you integrated the call back stuff into your Qt front end. You should run the program in your debugger and find out where it is crashing and the trigger event (even if not the cause). Otherwise we are all working in the dark.