Results 1 to 7 of 7

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,315
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

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

    For now I do not know how to check if the pointer is still valid
    It is good practice to either do a runtime check like this or to add an assert for debugging purposes like this:

    Qt Code:
    1. if ( e != nullptr )
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. assert( e != nullptr )
    To copy to clipboard, switch view to plain text mode 

    This doesn't help if the pointer is non-null but also not valid (in other words, you pass a pointer variable that has not been initialized).

    The assert will result in your program stopping at that point when you run it in the debugger. From that point, you can use the debugger to trace back through the call stack to find where things went wrong.

    If you don't know how to use a debugger, you have to learn. The dump you get from a SEGFAULT when running a realease mode version of your program is pretty much useless for debugging purposes.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. The following user says thank you to d_stranz for this useful post:

    teodor (11th January 2021)

Similar Threads

  1. Replies: 0
    Last Post: 9th January 2021, 13:07
  2. Replies: 1
    Last Post: 14th August 2014, 17:08
  3. Passing pointer to object that emits a signal
    By Gadgetman53 in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2011, 21:04
  4. qt signal/slot auto-connect issue
    By parnedo in forum Qt Programming
    Replies: 9
    Last Post: 16th July 2009, 12:55
  5. Passing a pointer in Signal/Slot Connection
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 6th November 2007, 19:04

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.