Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to terminate or destroy WorkerScript?
Forum Updated to NodeBB v4.3 + New Features

How to terminate or destroy WorkerScript?

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 5 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    at_pradeep
    wrote on last edited by
    #1

    I have one list view with list model.

    I am updating this list view from the worker thread as there is a huge data to load in the list.

    When my ListView gets destroyed then I want to stop/destroy my WorkerScript, as worker script tries to access ListModel (which is destroyed) and my application segments.

    So How should I destroy/terminate WorkerScript?

    Thanks.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      Just set WorkerScript.source to empty string

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • A Offline
        A Offline
        at_pradeep
        wrote on last edited by
        #3

        I tried to set the source to NULL in onDestroy of the List view screen but is does not work.

        I have one for loop in the Worker Script and that takes some time to finish and within this time if my list view gets destroyed then my application segments.

        If WorkerScript is in the for loop and if i set WorkerScript.source to blank string then it does not stop the WorkerScript from processing the for loop.

        What should i do on this, i am really stuck on this.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pong_Cpr.E.
          wrote on last edited by
          #4

          Can I using Qt.createComponent() in WorkerScript function?

          I'm new in Qt app.

          I wanna create dynamic image table(like in Samegame example) but it using thread to make real-time create by using workerScript.

          I known workerScript message can be passed between the new thread and the parent thread using sendMessage() and the onMessage() handler, but how with Qt function or can import in javascript.

          Thanks.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jinex2011
            wrote on last edited by
            #5

            All you need to do is when you exit from your list view, send a message to your script
            @
            WorkerScript.onMessage = function(msg)
            {
            if(msg.action == 'clear')
            {
            msg.model.clear();
            msg.model.sync();
            return;
            }
            }
            @

            "Nothing like the power of programming!"

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bibek
              wrote on last edited by
              #6

              As far as I know, Workerscript processes the instruction in a separate thread. There's very little way to control that separate thread.
              Instead of trying to destroy it, you might wanna try to stop it, but in that case, the stop instruction will be queued I suppose..

              Main tactic will be to design it in such a way that the separate thread doesn't affect the app even if listView instance gets destroyed

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved