Results 1 to 6 of 6

Thread: How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

    Hello.

    I need to process script in separate, non-gui thread since script calls C++ function that can take very long time to process (seconds). Is it possible to connect QScriptEngineDebugger to my QScriptEngine in non-gui thread? The problem is - if i put QScriptEngineDebugger in same thread as QScriptEngine (non-gui) than debugger will crash on debug - the code shows that it wants to create it's debug window and such window can be created only in gui thread. And if i place QScriptEngineDebugger in GUI thread application will crash since QScriptEngine is not multithread safe . Any insights?

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

    Default Re: How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

    I don't think that's possible. I'd suggest to process the script in the main thread and use QScriptEngine::setProcessEventsInterval() to prevent GUI from blocking.
    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
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

    As i mentioned, script calls back C++ code with functions that have very long execution time, so processing interval does nothing - it will not interrupt C++ function execution . Maybe it's possible to decouple script itself and execution of C++ functions somehow?

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

    Default Re: How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

    Is the C++ function Qt code too? You could call processEvents() there as well... Using a script debugger in a non-gui thread simply won't work as the engine is not thread-safe.
    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
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

    Thanks. It seems that processEvents() inside Qt C++ code is the only solution to use script debugger for long executing script .

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

    Default Re: How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

    You can also make your C++ call asynchronous. The contents of it can run in a separate thread while the script itself (and thus the main application) continues execution.
    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. External libary in a separate thread: is this correct?
    By sylvaticus in forum Qt Programming
    Replies: 1
    Last Post: 3rd December 2009, 08:47
  2. update widget from separate thread
    By method in forum Qt Programming
    Replies: 5
    Last Post: 10th July 2009, 14:33
  3. Accesing widgets from separate thread
    By msmihai in forum Qt Programming
    Replies: 2
    Last Post: 8th December 2008, 11:48
  4. new QWidget in separate thread
    By magland in forum Qt Programming
    Replies: 15
    Last Post: 7th February 2008, 12:32
  5. handling paintGL in a separate thread
    By al101 in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2007, 17: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.