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. Mainwindow closes when I close PCL window.
Forum Updated to NodeBB v4.3 + New Features

Mainwindow closes when I close PCL window.

Scheduled Pinned Locked Moved Unsolved General and Desktop
pcl
29 Posts 4 Posters 6.0k 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.
  • S surajj4837
    3 May 2021, 08:27

    @JonB https://www.geeksforgeeks.org/possible-call-constructor-destructor-explicitly/

    C Offline
    C Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on 3 May 2021, 08:28 last edited by Christian Ehrlicher 5 Mar 2021, 08:29
    #19

    @surajj4837 You must not call a dtor for an object when you created it on the stack as you did - no matter if you call it in an unusual way like you did or with the correct c++ way by calling delete. C++ basics.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    S 1 Reply Last reply 3 May 2021, 08:31
    1
    • S surajj4837
      3 May 2021, 08:27

      @JonB https://www.geeksforgeeks.org/possible-call-constructor-destructor-explicitly/

      J Offline
      J Offline
      JonB
      wrote on 3 May 2021, 08:28 last edited by JonB 5 Mar 2021, 08:29
      #20

      @surajj4837

      @JonB https://www.geeksforgeeks.org/possible-call-constructor-destructor-explicitly/

      Explicit call to destructor is only necessary when object is placed at particular location in memory by using placement new.

      Do you have any evidence this is the case for you?

      S 1 Reply Last reply 3 May 2021, 08:31
      0
      • S surajj4837
        3 May 2021, 08:25

        @jsulm The CloudViewer constructor definition says it creates the object on heap.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 3 May 2021, 08:30 last edited by
        #21

        @surajj4837 said in Mainwindow closes when I close PCL window.:

        The CloudViewer constructor definition says it creates the object on heap

        Please show its code. viewer itself is allocated on the stack as you can clearly see from your code...

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply 3 May 2021, 08:32
        0
        • C Christian Ehrlicher
          3 May 2021, 08:28

          @surajj4837 You must not call a dtor for an object when you created it on the stack as you did - no matter if you call it in an unusual way like you did or with the correct c++ way by calling delete. C++ basics.

          S Offline
          S Offline
          surajj4837
          wrote on 3 May 2021, 08:31 last edited by
          #22

          @Christian-Ehrlicher Okay

          1 Reply Last reply
          0
          • J JonB
            3 May 2021, 08:28

            @surajj4837

            @JonB https://www.geeksforgeeks.org/possible-call-constructor-destructor-explicitly/

            Explicit call to destructor is only necessary when object is placed at particular location in memory by using placement new.

            Do you have any evidence this is the case for you?

            S Offline
            S Offline
            surajj4837
            wrote on 3 May 2021, 08:31 last edited by
            #23

            @JonB No.

            1 Reply Last reply
            0
            • J jsulm
              3 May 2021, 08:30

              @surajj4837 said in Mainwindow closes when I close PCL window.:

              The CloudViewer constructor definition says it creates the object on heap

              Please show its code. viewer itself is allocated on the stack as you can clearly see from your code...

              S Offline
              S Offline
              surajj4837
              wrote on 3 May 2021, 08:32 last edited by
              #24

              @jsulm Official source code. Line #266.

              J C 4 Replies Last reply 3 May 2021, 08:32
              0
              • S surajj4837
                3 May 2021, 08:32

                @jsulm Official source code. Line #266.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 3 May 2021, 08:32 last edited by
                #25

                @surajj4837 said in Mainwindow closes when I close PCL window.:

                Line #266.

                What is in that line?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • S surajj4837
                  3 May 2021, 08:32

                  @jsulm Official source code. Line #266.

                  C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 3 May 2021, 08:33 last edited by
                  #26

                  @surajj4837 said in Mainwindow closes when I close PCL window.:

                  @jsulm Official source code. Line #266.

                  There the object itself creates a new object on the heap. Don't know what this should have to do with your object which you create on the stack though.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • S surajj4837
                    3 May 2021, 08:32

                    @jsulm Official source code. Line #266.

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 3 May 2021, 08:35 last edited by jsulm 5 Mar 2021, 08:35
                    #27

                    @surajj4837 This does not change anything! viewer is allocated on the stack. Its constructor allocates something on the heap but that is deleted in the destructor. But you do not have to call destructor for objects allocated on the stack as it is called when the object is destroyed (if it leaves its scope). I suggest you learn C++ basics (memory management).

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    S 1 Reply Last reply 3 May 2021, 08:38
                    1
                    • S surajj4837
                      3 May 2021, 08:32

                      @jsulm Official source code. Line #266.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 3 May 2021, 08:37 last edited by
                      #28

                      @surajj4837 Actually there seems to be a bug:

                      00270 pcl::visualization::CloudViewer::~CloudViewer ()
                      00271 {
                      00272   impl_->quit_ = true;
                      00273   impl_->viewer_thread_.join();
                      00274 }
                      00275 
                      

                      Destructor does not delete impl!
                      It should be

                      pcl::visualization::CloudViewer::~CloudViewer ()
                      {
                         impl_->quit_ = true;
                         impl_->viewer_thread_.join();
                         delete impl;
                      }
                      

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • J jsulm
                        3 May 2021, 08:35

                        @surajj4837 This does not change anything! viewer is allocated on the stack. Its constructor allocates something on the heap but that is deleted in the destructor. But you do not have to call destructor for objects allocated on the stack as it is called when the object is destroyed (if it leaves its scope). I suggest you learn C++ basics (memory management).

                        S Offline
                        S Offline
                        surajj4837
                        wrote on 3 May 2021, 08:38 last edited by
                        #29

                        @jsulm Sure, I will do that.

                        1 Reply Last reply
                        0

                        28/29

                        3 May 2021, 08:37

                        • Login

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