Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qtconcurrent cancel without leak memory
Qt 6.11 is out! See what's new in the release blog

qtconcurrent cancel without leak memory

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.6k Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi,

    I create some resources with new command in heavy job and I want to cancel it. Is it possible to delete the pointer only if it was alocate?

    future_ = QtConcurrent::run(this, &Class::foo);
    
    Class::foo() {
        int* bar = new int;
        sleep(1000);
    }
    
    Q_SLOT:
        void cancel_button(){
            future_.cancel();
        }
    

    Regards,
    Robin

    1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      Hi,
      AFAIK you cannot cancel QtConcurrent::run anyway, using future_.cancel().

      You can cancel only QtConcurrent computations that work on a container handling each of its members in a separate thread, as to cancel in QtConcurrent means to start no new threads anymore. It does not mean to stop already running threads.
      -Michael.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thank you for your reply. My button cancel unrun job and wait for running thread.
        Robin

        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