Results 1 to 1 of 1

Thread: Issue when passing a pointer to a SLOT from a SIGNAL with QObject::connect

  1. #1
    Join Date
    Jan 2021
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Issue when passing a pointer to a SLOT from a SIGNAL with QObject::connect

    Hi,

    I am using connect in order to send a SIGNAL with 2 variables towards a SLOT. The connect looks like this:

    Qt Code:
    1. const bool connected = QObject::connect(this, &iVoiceCom:: stateCallChangedT,this, &iVoiceCom:: onCallStateChanged, Qt::QueuedConnection);
    2. qDebug() << "Connection established?" << connected;
    To copy to clipboard, switch view to plain text mode 
    In the main I am defining the variables to be passed from
    qRegisterMetaType<pjsua_call_id>("pjsua_call_id");
    qRegisterMetaType<pjsip_event*>("pjsip_event");

    Then in this function I run the emit with the 2 varialbes, one int and a pointer:

    Qt Code:
    1. void iVoiceCom:: on_call_state(pjsua_call_id call_id, pjsip_event *e)
    2. {
    3. //callStateChanged(call_id,e);
    4. emit stateCallChangedT(call_id, e);
    5. }
    To copy to clipboard, switch view to plain text mode 

    The SIGNAL is emited OK and the function below is run, but the "e" pointer is passed until a certain point

    e->type OK
    e->body.tsx_state.type OK

    BUT

    e->body.tsx_state.src.rdata->msg_info.msg; is LOST and I do not understand why, the back trace from gdb:

    Program received signal SIGSEGV, Segmentation fault.
    0x00000000004226da in iVoiceCom:: onCallStateChanged (this=0x7fffffffc9d0, call_id=0, e=0x7fffc7ffdfe0) at iVoiceCom.cpp:1605
    1605 int code = msg->line.status.code;
    (gdb) p e->type
    $1 = PJSIP_EVENT_TSX_STATE
    (gdb) p e->body.tsx_state.type
    $2 = PJSIP_EVENT_RX_MSG
    (gdb) p e->body.tsx_state.src.rdata->msg_info
    $7 = {msg_buf = 0x0, len = 0, msg = 0x0, info = 0x0, cid = 0x0, from = 0x0, to = 0x0, via = 0x0, cseq = 0x0, max_fwd = 0x0, route = 0x0, record_route = 0x0, ctype = 0x0, clen = 0x0, require = 0x0,
    supported = 0x0, parse_err = {prev = 0x0, next = 0x0, except_code = 0, line = 0, col = 0, hname = {ptr = 0x0, slen = 0}}}
    (gdb)

    The slot/function:
    Qt Code:
    1. void iVoiceCom:: onCallStateChanged(pjsua_call_id call_id, pjsip_event *e)
    2. {
    3. ....
    4. if (e->type == PJSIP_EVENT_TSX_STATE)
    5. {
    6. pjsip_msg *msg;
    7.  
    8. if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG)
    9. {
    10. msg = e->body.tsx_state.src.rdata->msg_info.msg;
    11. }
    12. else {
    13. msg = e->body.tsx_state.src.tdata->msg;
    14. }
    15.  
    16. int code = msg->line.status.code;
    17. ...
    18. }
    To copy to clipboard, switch view to plain text mode 

    Can you please help me to understand what am I doing wrong.

    Thank You!
    Teo
    Last edited by d_stranz; 9th January 2021 at 17:04. Reason: missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 14th August 2014, 18:08
  2. Passing pointer to object that emits a signal
    By Gadgetman53 in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2011, 22:04
  3. qt signal/slot auto-connect issue
    By parnedo in forum Qt Programming
    Replies: 9
    Last Post: 16th July 2009, 13:55
  4. QObject::connect: No such slot !?!
    By Mystical Groovy in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 19:31
  5. Passing a pointer in Signal/Slot Connection
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 6th November 2007, 20:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.