Results 1 to 11 of 11

Thread: Event Processing

  1. #1
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Event Processing

    Hi,
    I had a similar issue before, but now it's more apparent.
    I am sending events with QTCLASS]QCopChannel::sendEvent()[[/QTCLASS], the receiver object is not receiving these events for some period of time later. When I cause another window event, painting, mouseevent, then the events are flushed and sent.
    As a test I made a QTimer object with a timeout of 0, this is suppose to timeout when the eventloop is idle, so I put a debug() statement in this slot and it is called all the time, so the receiver object is always in an idle state. However strange enough, without doing anything in the timeout slot, the QCop events are now being received by my receiver object. So, my receiver object is always idle, I though when idling the QApplication::processEvents is being called in the eventloop.
    What does this mean?
    thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Processing

    Did you check whether the problem is on sending or receiving end?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Event Processing

    I debugged the sending routine QCopChannel::send(), returns true, which means successful, and the event and channel are correct at that point.
    In the receiver object I debug when I receive an event, but nothing was being received. So, the sending is doing as it should, but the event is not being processed. (rec'd).

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Processing

    Do you use multiple threads? Is there a chance you are starving the event loop?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Event Processing

    Yes I have mulitple threads, 3 other threads. I commented out only 2 threads, because thread 1 does the QCop sending.
    With just the one thread it still exhibits this problem. In that one thread it is a blocking read call, so if there is nothing to read it blocks. I thought during blocking the other threads have a chance to run.
    Is that a problem?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Processing

    Do you have an event loop running in the thread receiving QCop messages? Where (in which thread and which method) did you create the QCopChannel object?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Event Processing

    Yes, at least I hope I have an event loop running. In my main this is my code..just the basics.
    Qt Code:
    1. TestProgram test;
    2. test.show();
    3. splash.finish(&test);
    4. return app.exec();
    To copy to clipboard, switch view to plain text mode 

    In my 'test' object I receive the QCop events. The QCopChannel object is being created in my 'test' object.
    Qt Code:
    1. QCopChannel *myEvents = new QCopChannel(GPIO);
    2. connect(myEvents,SIGNAL(received(const QString &, const QByteArray &)),
    3. this, SLOT(readProcessEvents(const QString &, const QByteArray &)));
    To copy to clipboard, switch view to plain text mode 


    My one thread that sends the QCop events uses the QCopChannel::send() static function. Here is my sending routine.
    Qt Code:
    1. int sendQCopEvent( char *channel, char *string, const QByteArray &data)
    2. {
    3. if(QCopChannel::isRegistered(channel))
    4. {
    5. QCopChannel::send(channel, string, data);
    6. QCopChannel::flush();
    7. // qDebug() << channel << string << __FUNCTION__ << endl;
    8. return 0;
    9. }
    10. return -1;
    11. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Processing

    The code looks fine. I understand the last piece of code is in a different application than previous ones?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Event Processing

    yes, sort of.
    The last piece of code is a routine called by my thread. My thread is written in C code. It is all compiled into one application.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Processing

    So why do you need the channel in the first place? Why not pass the data directly?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Event Processing

    Yes I realize I could pass the data directly however when I first started the design they were two separate processes. In order to ease the transition, and leave it open to keep them separate I kept the QCopChannel scheme.
    My 'test' object needs to monitor the thread for events.

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Custom event gets not propagated to the top level widget
    By nightghost in forum Qt Programming
    Replies: 0
    Last Post: 29th January 2009, 09:06
  3. Event propagation direction
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2008, 21:03
  4. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

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.