Results 1 to 8 of 8

Thread: QSriptEngine and more than one script

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QSriptEngine and more than one script

    Quote Originally Posted by lukass View Post
    If I use pushContext() then how can I "unload" particular script?
    I don't understand what you mean.

    And are there other ways? If so, how?
    For example you could set a new global object for the engine.

    Let's make something clear -- one script engine only allows one script to be ran at the same time. If you want to run more (long running) scripts concurrently, you need separate engines however doing that in a single thread doesn't make much sense. Doing that in different threads requires you to synchronize access to all data shared between those scripts and also between your main program flow (aka "GUI thread").
    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.


  2. #2
    Join Date
    Aug 2008
    Posts
    50
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: QSriptEngine and more than one script

    Quote Originally Posted by wysota View Post
    I don't understand what you mean.
    For example I loaded three scripts by:
    Qt Code:
    1. engine.evaluate(script1);
    2. engine.pushContext();
    3. engine.evaluate(script2);
    4. engine.pushContext();
    5. engine.evaluate(script3);
    To copy to clipboard, switch view to plain text mode 
    I can unload last script by engine.popContext() but how can I unload first script?

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

    Default Re: QSriptEngine and more than one script

    The code you pasted doesn't make sense. The following should be fine:

    Qt Code:
    1. engine.pushContext();
    2. engine.evaluate(script1);
    3. engine.popContext();
    4. engine.pushContext();
    5. engine.evaluate(script2);
    6. engine.popContext();
    7. engine.pushContext();
    8. engine.evaluate(script3);
    9. engine.popContext();
    To copy to clipboard, switch view to plain text mode 

    You don't "unload" scripts. When a script has finished executing you don't have to do anything more with it.
    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. script
    By wookoon in forum Newbie
    Replies: 1
    Last Post: 19th July 2010, 10:47
  2. Using QT Script...
    By minhaz in forum Newbie
    Replies: 1
    Last Post: 18th August 2009, 23:29
  3. Qt Script
    By c_srikanth1984 in forum Qt Programming
    Replies: 3
    Last Post: 9th June 2009, 11:35
  4. Can I include a script from script?
    By yycking in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2009, 04:01
  5. Qt script
    By rajesh_clt3 in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2007, 13:40

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.