Results 1 to 6 of 6

Thread: Different behaviour between linux and embedded implementation

  1. #1
    Join Date
    Apr 2014
    Posts
    7
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Different behaviour between linux and embedded implementation

    Hi!

    I have an app. stating a thread to do some calculations. This is code to start the thread and to connect the signals between the mainwindow and the thread:
    Qt Code:
    1. m_calcProc = new BaseCalcProccess();
    2. m_calcProc->moveToThread(&m_thread);
    3.  
    4. connect(&m_thread, SIGNAL(started()), m_calcProc, SLOT(run()));
    5. connect(m_calcProc, SIGNAL(start()), &m_thread, SLOT(start()));
    6. connect(m_calcProc, SIGNAL(stop()), &m_thread, SLOT(quit()));
    7.  
    8. m_calcProc->started();
    To copy to clipboard, switch view to plain text mode 

    the m_thread is a QThread variable defined in MainWindow

    the class BaseCalcProccess is a "public QObject"

    and for this class I have the follwing code:
    Qt Code:
    1. void BaseCalcProccess::started()
    2. {
    3. m_threadData.LoopOn = true;
    4. emit start();
    5. }
    6.  
    7. void BaseCalcProccess::stopped()
    8. {
    9. m_threadData.LoopOn = false;
    10. emit stop();
    11. usleep(50000);
    12. }
    13.  
    14. void BaseCalcProccess::run(void )
    15. {
    16. ............
    To copy to clipboard, switch view to plain text mode 
    the code had been compiled with QtCreator 3.1.1 (based on Qt 5.2.1) and tested in ubuntu 13.10 without any problems!

    Then I compiled with Qt 4.8.2 for embedded linux (ARM) and started the application in the target env. and everything is working as expected BUT the "started"-signal is not been triggered or at least, there is no call to the RUN-method for the BaseCalcProccess!!
    I had been trying to find some explanations to this behaviour or some way to narrow down the problem without any success, so any advices, suggestions or help is much appreciated!

  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: Different behaviour between linux and embedded implementation

    I'd suggest simplifying your code and making sure signal and slot names are easily distinguishable. Right now it is quite confusing as you have 'start' and 'started' signals and slots everywhere.

    If you just have a simple run() function that has fire-and-forget semantics then instead of using QThread and a custom class I suggest to use QRunnable or QtConcurrent::run().
    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
    Apr 2014
    Posts
    7
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Different behaviour between linux and embedded implementation

    I simplified the code so now I just have one connection between the thread and the mainwindow:
    Qt Code:
    1. m_calcProc = new BaseCalcProccess();
    2. m_calcProc->moveToThread(&m_thread);
    3. connect(&m_thread, SIGNAL(started()), m_calcProc, SLOT(run()));
    4. m_calcProc->started();
    To copy to clipboard, switch view to plain text mode 

    and AGAIN: with QtCreator 3.1.1 (based on Qt 5.2.1) in ubuntu 13.10, works without any problems!
    when compiled with Qt 4.8.2 for embedded linux (ARM) is not triggering the run-method!!!!!

  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: Different behaviour between linux and embedded implementation

    In my opinion you should explicitly start the thread first if you really have to complicate your life.
    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
    Apr 2014
    Posts
    7
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Different behaviour between linux and embedded implementation

    But still the question remains: why it works in one env. but not in the other........
    How can I find/narrow down the origin of this behaviour?

  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: Different behaviour between linux and embedded implementation

    Quote Originally Posted by tescik View Post
    But still the question remains: why it works in one env. but not in the other........
    How can I find/narrow down the origin of this behaviour?
    Probably Qt5 contains some fix or behavior change related to threads and signal handling which isn't present in Qt 4.
    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.


Similar Threads

  1. Replies: 5
    Last Post: 25th April 2012, 11:34
  2. difference between source in Qt for X11/Linux Qt for Embedded Linux
    By sanjeet in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 7th June 2011, 02:58
  3. Replies: 2
    Last Post: 4th June 2009, 16:09
  4. Multiple apps using Qt/Embedded+Qtopia on Embedded Linux
    By drahardja in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 17th February 2008, 21:46

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.