Results 1 to 7 of 7

Thread: Emitting a signal is corrupting data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Nov 2010
    Posts
    315
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanked 53 Times in 51 Posts

    Default Re: Emitting a signal is corrupting data

    Still this gives almost nothing.
    At least it seems you did something wrong.
    Emitting and reciving in slot a pointer value is disturbing solution especially in mutithreding case.
    I also suspect that you are using lock in wrong way.

    The safest way to solve mutithreading producer consumer problem in Qt is:
    Define QObjects class representing producer and consumer (do NOT subclass QThread!!!).
    Create needed QThreads and move instances of producer (QObject::moveToThread) and consumer to proper threads.
    Connect signal of producer to respective slot of consumer.
    To pass by value custom structure by a signal slot mechanism declare and define meta data for this custom type (instruction can be found in documentation).
    Use of default Qt type is recommended (QList, QVector insted std::list and std:vector).
    Note that consumer should be faster then producer or event queue of consumer may grow.

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

    pan (7th July 2011)

Similar Threads

  1. Problem emitting a signal
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2009, 00:56
  2. Emitting signal from DLL to EXE
    By Miihkali in forum Qt Programming
    Replies: 6
    Last Post: 27th March 2009, 08:32
  3. disconnect SIGNAL/SLOT directly after emitting data
    By donglebob in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2009, 22:53
  4. Replies: 3
    Last Post: 21st December 2008, 12:23
  5. cost of emitting signal
    By quickNitin in forum Newbie
    Replies: 1
    Last Post: 29th November 2006, 08:53

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.