Results 1 to 4 of 4

Thread: Problems with a Thread

  1. #1
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problems with a Thread

    Hi

    I tried to restart a thread (after exit them), but when I push the restart button the program crashed and the debuger showed the following message: "QObject: Cannot create children for a parent that is in a different thread.(Parent is QTcpSocket(0x811a274), parent's thread is QThread(0x81367c0), current thread is OptimizationThread(0x81a6d90)"

    What could be the problem?

    The code to restart is this:
    Qt Code:
    1. pause = false;
    2. if (!isRunning())
    3. {
    4. start(QThread::LowPriority);
    5. }
    6. else
    7. {
    8. condition.wakeOne();
    9. quit();
    10. if (!isRunning())
    11. {
    12. start(QThread::LowPriority);
    13. }
    14. else
    15. {
    16. qDebug()<<"Error";
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

    I use Qt 4.4.3 and ubuntu

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problems with a Thread

    Could you show more code? You've got a bug there, but it's hard to say without seeing more code. Be especially careful with slots in QThread subclasses. You can search the forums for more details on the subject.
    J-P Nurmi

  3. #3
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face Re: Problems with a Thread

    Ok, I Attach the code for the thread and the dialog uses this thread.

    Thanks you
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problems with a Thread

    Ok, how about defining QT_FATAL_WARNINGS=1 environment variable and getting the backtrace from a debugger?
    J-P Nurmi

Similar Threads

  1. postEvent & Thread problems
    By gianpatt in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2008, 14:19
  2. canonicalFilePath() thread problems
    By magland in forum Qt Programming
    Replies: 10
    Last Post: 5th December 2007, 21:22
  3. Thread Problems (i think)
    By LMZ in forum Qt Programming
    Replies: 11
    Last Post: 29th September 2007, 12:54
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49

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.