Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. pointer changing, without using anything in code
Qt 6.12 LTS is out! See what's new in the release blog

pointer changing, without using anything in code

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.8k Views 2 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.
  • M Offline
    M Offline
    mchinand
    wrote on last edited by
    #2

    I think people are going to need more than your two connect statements to tell you what's wrong with your code.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      micha_eleric
      wrote on last edited by
      #3

      my code is not changing the value of the pointer. the pointer is randomly changing from outside of my code

      1 Reply Last reply
      0
      • M Offline
        M Offline
        micha_eleric
        wrote on last edited by micha_eleric
        #4
        int main(int argc, char **argv)
        {
            std::cout << "__name__\n" << std::flush;
            QApplication app (argc, argv);
            CNC::CThreadController *threcon = new CNC::CThreadController();
            std::cout << "main threcon = " << threcon << '\n' << std::flush;
            CNC::CGUI *gui = new CNC::CGUI();
            std::cout << "main gui = " << gui << '\n' << std::flush;
            CNC::CControls *cont = new CNC::CControls();
            std::cout << "main cont = " << cont << '\n' << std::flush;
            threcon->SetGUI(gui);
            threcon->SetControls(cont);
            gui->SetController(threcon);
            cont->SetController(threcon);
            threcon->startThreads();
            gui->show();
            return app.exec();
            //return 1;
        }
        
        
        void CThreadController::SetControls(CControls *cont)
            {
                std::cout << "CThreadController cont = " << cont << '\n' << std::flush;
                m_controls = cont;
            }
        
            void CThreadController::SetGUI(CGUI *gui)
            {
                std::cout << "CThreadController gui = " << gui << '\n' << std::flush;
                m_gui = gui;
            }
        
        void CGUI::SetController(CThreadController *controller)
            {
                std::cout << "CGUI::SetController controller = " << controller << '\n' << std::flush;
                m_threadcontroller = controller;
            }
        
        void CControls::SetController(CThreadController *controller)
            {
                std::cout << "CControls::SetController begin \n" << std::flush;
                m_threadcontroller = controller;
            }
        
        void CThreadController::startThreads()
            {
                std::cout << "CThreadController::startThreads() begin\n" << std::flush;
        
                //?? does (this) have to be sent to CNC::CControls(this);?
                //CNC::CControls *controlsThread = new CNC::CControls(this);
                //?? connect(m_controls, signal, this, slots);
                connect(m_controls, &CNC::CControls::finished, this, &QObject::deleteLater);
        
                connect(m_controls, &CNC::CControls::emitMessageBoxRed, m_gui, &CNC::CGUI::RecieveMessageBoxRed);
        
        
                //?? gui
                connect(m_gui, &CNC::CGUI::emitBitDia, m_controls, &CNC::CControls::SetBitDia);
        
                connect(m_gui, &CNC::CGUI::emitMove_To, m_controls, &CNC::CControls::Move_To);
        
                connect(m_gui, &CNC::CGUI::emitMove_A_axis, m_controls, &CNC::CControls::Move_A_axis);
                connect(m_gui, &CNC::CGUI::emitMove_B_axis, m_controls, &CNC::CControls::Move_B_axis);
                connect(m_gui, &CNC::CGUI::emitMove_C_axis, m_controls, &CNC::CControls::Move_C_axis);
                connect(m_gui, &CNC::CGUI::emitMove_X_axis, m_controls, &CNC::CControls::Move_X_axis);
                connect(m_gui, &CNC::CGUI::emitMove_Y_axis, m_controls, &CNC::CControls::Move_Y_axis);
                connect(m_gui, &CNC::CGUI::emitMove_Z_axis, m_controls, &CNC::CControls::Move_Z_axis);
        
                connect(m_gui, &CNC::CGUI::emitMin_A, m_controls, &CNC::CControls::SetMin_A);
                connect(m_gui, &CNC::CGUI::emitMin_B, m_controls, &CNC::CControls::SetMin_B);
                connect(m_gui, &CNC::CGUI::emitMin_C, m_controls, &CNC::CControls::SetMin_C);
                connect(m_gui, &CNC::CGUI::emitMin_X, m_controls, &CNC::CControls::SetMin_X);
                connect(m_gui, &CNC::CGUI::emitMin_Y, m_controls, &CNC::CControls::SetMin_Y);
                connect(m_gui, &CNC::CGUI::emitMin_Z, m_controls, &CNC::CControls::SetMin_Z);
        
                connect(m_gui, &CNC::CGUI::emitMax_A, m_controls, &CNC::CControls::SetMax_A);
                connect(m_gui, &CNC::CGUI::emitMax_B, m_controls, &CNC::CControls::SetMax_B);
                connect(m_gui, &CNC::CGUI::emitMax_C, m_controls, &CNC::CControls::SetMax_C);
                connect(m_gui, &CNC::CGUI::emitMax_X, m_controls, &CNC::CControls::SetMax_X);
                connect(m_gui, &CNC::CGUI::emitMax_Y, m_controls, &CNC::CControls::SetMax_Y);
                connect(m_gui, &CNC::CGUI::emitMax_Z, m_controls, &CNC::CControls::SetMax_Z);
        
                connect(m_gui, &CNC::CGUI::emitNumPinPerBoard, m_controls, &CNC::CControls::SetNumPinPerBoard);
                connect(m_gui, &CNC::CGUI::emitRun, m_controls, &CNC::CControls::Run);
        
        
                connect(m_gui, &CNC::CGUI::emitPortName_1, m_controls, &CNC::CControls::SetPortName_1);
                connect(m_gui, &CNC::CGUI::emitPortName_1, m_controls, &CNC::CControls::SetPortName_2);
                connect(m_gui, &CNC::CGUI::emitPortName_1, m_controls, &CNC::CControls::SetPortName_3);
                connect(m_gui, &CNC::CGUI::emitPortName_1, m_controls, &CNC::CControls::SetPortName_4);
        
                connect(m_gui, &CNC::CGUI::emitSer_1_connected, m_controls, &CNC::CControls::SetSer_1_connected);
                connect(m_gui, &CNC::CGUI::emitSer_2_connected, m_controls, &CNC::CControls::SetSer_2_connected);
                connect(m_gui, &CNC::CGUI::emitSer_3_connected, m_controls, &CNC::CControls::SetSer_3_connected);
                connect(m_gui, &CNC::CGUI::emitSer_4_connected, m_controls, &CNC::CControls::SetSer_4_connected);
        
                connect(m_gui, &CNC::CGUI::emitState, m_controls, &CNC::CControls::SetState);
                connect(m_gui, &CNC::CGUI::emitStepMtrPst, m_controls, &CNC::CControls::SetStepMtrPst);
        
                m_controls->start();
        
                std::cout << "CThreadController::startThreads() end\n" << std::flush;
            }
        
        void CGUI::Btn_motor_update_Clicked()
            {
                std::cout << "Btn_motor_update_Clicked begin \n" << std::flush;
                try
                {
                    //?? number pin per board ?? var name?
                    int temp = (ui->textEdit_21->toPlainText()).toInt();
                    std::cout << "CGUI::Btn_motor_update_Clicked pin = " << temp << '\n' << std::flush;
                    emit emitNumPinPerBoard(temp);
        
                    temp = (ui->textEdit_20->toPlainText()).toInt();
                    std::cout << "CGUI::Btn_motor_update_Clicked step = " << temp << '\n' << std::flush;
                    emit emitStepMtrPst(temp);
        
                    std::cout << "CGUI::Btn_motor_update_Clicked m_threadcontroller = " << m_threadcontroller << '\n' << std::flush;
                    m_threadcontroller->SetNumMotorPos();
        
                    std::cout << "Btn_motor_update_Clicked 4 \n" << std::flush;
                    MessageBoxYellow("Number position on motors, & Number of pins per board, updated");
                    std::cout << "Btn_motor_update_Clicked 5 \n" << std::flush;
                }
                catch(std::exception& e)
                {
                    MessageBoxError(e.what());
                }
                std::cout << "Btn_motor_update_Clicked end \n" << std::flush;
            }
        
        void CControls::SetNumPinPerBoard(int n)
            {
                //std::cout << "CControls::SetNumPinPerBoard begin \n" << std::flush;
                std::cout << "CControls::SetNumPinPerBoard this = " << this <<  '\n' << std::flush;
                std::cout << "CControls::SetNumPinPerBoard n = " << n << '\n' << std::flush;
        
                m_iNumPinPerBoard = n;
            }
        
        void CControls::SetStepMtrPst(int n)
            {
                //std::cout << "CControls::SetStepMtrPst \n" << std::flush;
                std::cout << "CControls::SetStepMtrPst n = " << n <<  '\n' << std::flush;
                std::cout << "CControls::SetStepMtrPst this = " << this <<  '\n' << std::flush;
        
                m_iStepMtrPst = n;
                std::cout << "CControls::SetStepMtrPst m_iStepMtrPst = " << m_iStepMtrPst <<  '\n' << std::flush;
        
            }
        
        void CThreadController::SetNumMotorPos()
            {
                std::cout << "CThreadController::SetNumMotorPos m_controls = " << m_controls << '\n' << std::flush;
                m_controls->SetNumMotorPos();
            }
        
        void CControls::SetNumMotorPos()
            {
                std::cout << "CControls::SetNumMotorPos begin \n" << std::flush;
                std::cout << "CControls::SetNumMotorPos this = " << this <<  '\n' << std::flush;
                std::cout << "CControls::SetNumMotorPos m_iStepMtrPst = " << std::flush;
                std::cout << m_iStepMtrPst << '\n' << std::flush;
        
                m_motor_A_axis.SetNumMotorPos(m_iStepMtrPst);
                m_motor_B_axis.SetNumMotorPos(m_iStepMtrPst);
                m_motor_C_axis.SetNumMotorPos(m_iStepMtrPst);
        
                m_motor_X_axis.SetNumMotorPos(m_iStepMtrPst);
                m_motor_Y_axis.SetNumMotorPos(m_iStepMtrPst);
                m_motor_Z_axis.SetNumMotorPos(m_iStepMtrPst);
        
                std::cout << "CControls::SetNumMotorPos end \n" << std::flush;
            }
        

        since the address to CControls object is set in main, and nothing in my code creates a new CThreadController object, why is CControls object changing?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          micha_eleric
          wrote on last edited by micha_eleric
          #5
          __name__
          CThreadController::CThreadController  () 
          main threcon = 0x564ac2f50fe0
          CGUI::CGUI() 
          CGUI::InitTestBoard 
          InitTestBoard try begin 
          InitTestBoard try 2 
          InitTestBoard try end 
          CGUI::InitDistance 
          CGUI::InitCalibration 
          CGUI::InitMotor 
          main gui = 0x564ac2f677c0
          main cont = 0x564ac3478010
          CThreadController gui = 0x564ac2f677c0
          CThreadController cont = 0x564ac3478010
          CGUI::SetController controller = 0x564ac2f50fe0
          CControls::SetController begin 
          CThreadController::startThreads begin
          CThreadController::startThreads m_controls = 0x564ac3478010
          CThreadController::startThreads m_gui = 0x564ac2f677c0
          CThreadController::startThreads this = 0x564ac2f50fe0
          CThreadController::startThreads m_controls = 0x564ac3478010
          CThreadController::startThreads m_gui = 0x564ac2f677c0
          CThreadController::startThreads() end
          CThreadController::ShowPointers m_controls = 0x564ac3478010
          CThreadController::ShowPointers m_gui = 0x564ac2f677c0
          Btn_motor_update_Clicked begin 
          CGUI::Btn_motor_update_Clicked pin = 12
          CControls::SetNumPinPerBoard this = 0x564ac3478010
          CControls::SetNumPinPerBoard n = 12
          CGUI::Btn_motor_update_Clicked step = 4
          CControls::SetStepMtrPst n = 4
          CControls::SetStepMtrPst this = 0x564ac3478010
          CControls::SetStepMtrPst m_iStepMtrPst = 4
          CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x564ac2f50fe0
          CThreadController::SetNumMotorPos m_controls = 0x564ac3492190
          CThreadController::SetNumMotorPos m_gui = 0x564a800000ee
          CControls::SetNumMotorPos begin 
          CControls::SetNumMotorPos this = 0x564ac3492190
          CControls::SetNumMotorPos m_threadcontroller = 0x7f74f0b38980
          CControls::SetNumMotorPos m_iStepMtrPst = 0
          CMotor::SetNumMotorPos begin 
          num = 0
          error: CMotor.SetNumMotorPos() 
          Btn_motor_update_Clicked end 
          Press <RETURN> to close this window...
          
          

          where and why is class data m_controls and m_gui changing in class CThreadController?

          class data m_threadcontroller is not changing in class CGUI, but is changing in class CControls?

          Christian EhrlicherC 1 Reply Last reply
          0
          • M micha_eleric
            __name__
            CThreadController::CThreadController  () 
            main threcon = 0x564ac2f50fe0
            CGUI::CGUI() 
            CGUI::InitTestBoard 
            InitTestBoard try begin 
            InitTestBoard try 2 
            InitTestBoard try end 
            CGUI::InitDistance 
            CGUI::InitCalibration 
            CGUI::InitMotor 
            main gui = 0x564ac2f677c0
            main cont = 0x564ac3478010
            CThreadController gui = 0x564ac2f677c0
            CThreadController cont = 0x564ac3478010
            CGUI::SetController controller = 0x564ac2f50fe0
            CControls::SetController begin 
            CThreadController::startThreads begin
            CThreadController::startThreads m_controls = 0x564ac3478010
            CThreadController::startThreads m_gui = 0x564ac2f677c0
            CThreadController::startThreads this = 0x564ac2f50fe0
            CThreadController::startThreads m_controls = 0x564ac3478010
            CThreadController::startThreads m_gui = 0x564ac2f677c0
            CThreadController::startThreads() end
            CThreadController::ShowPointers m_controls = 0x564ac3478010
            CThreadController::ShowPointers m_gui = 0x564ac2f677c0
            Btn_motor_update_Clicked begin 
            CGUI::Btn_motor_update_Clicked pin = 12
            CControls::SetNumPinPerBoard this = 0x564ac3478010
            CControls::SetNumPinPerBoard n = 12
            CGUI::Btn_motor_update_Clicked step = 4
            CControls::SetStepMtrPst n = 4
            CControls::SetStepMtrPst this = 0x564ac3478010
            CControls::SetStepMtrPst m_iStepMtrPst = 4
            CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x564ac2f50fe0
            CThreadController::SetNumMotorPos m_controls = 0x564ac3492190
            CThreadController::SetNumMotorPos m_gui = 0x564a800000ee
            CControls::SetNumMotorPos begin 
            CControls::SetNumMotorPos this = 0x564ac3492190
            CControls::SetNumMotorPos m_threadcontroller = 0x7f74f0b38980
            CControls::SetNumMotorPos m_iStepMtrPst = 0
            CMotor::SetNumMotorPos begin 
            num = 0
            error: CMotor.SetNumMotorPos() 
            Btn_motor_update_Clicked end 
            Press <RETURN> to close this window...
            
            

            where and why is class data m_controls and m_gui changing in class CThreadController?

            class data m_threadcontroller is not changing in class CGUI, but is changing in class CControls?

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @micha_eleric said in pointer changing, without using anything in code:

            where and why is class data m_controls and m_gui changing in class CThreadController?

            Provide a minimal, compilable example instead posting the whole question over and over without any real information.

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

            M 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @micha_eleric said in pointer changing, without using anything in code:

              where and why is class data m_controls and m_gui changing in class CThreadController?

              Provide a minimal, compilable example instead posting the whole question over and over without any real information.

              M Offline
              M Offline
              micha_eleric
              wrote on last edited by
              #7

              @Christian-Ehrlicher said in pointer changing, without using anything in code:

              @micha_eleric said in pointer changing, without using anything in code:

              where and why is class data m_controls and m_gui changing in class CThreadController?

              Provide a minimal, compilable example instead posting the whole question over and over without any real information.

              i assume the minimum would be no code, since i can not find anything in my code to create the error. i posted everything of my code, where the error showed up. i keep adding more std::cout, trying to figure out between my code and my code it is happening.

              Paul ColbyP 1 Reply Last reply
              0
              • M Offline
                M Offline
                micha_eleric
                wrote on last edited by
                #8

                added

                std::cout << "CControls::SetNumMotorPos m_threadcontroller = " << m_threadcontroller << '\n' << std::flush;
                

                causes it to crash with multiple tries.
                what i thought was a different m_threadcontroller in CControls, but was also a different CControls object, which i still question where the second CControls and CGUI object came from, when no new objects are created

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  micha_eleric
                  wrote on last edited by
                  #9

                  finally got a try to not crash

                  main threcon = 0x55b88df8dd00
                  CGUI::CGUI() 
                  CGUI::InitTestBoard 
                  InitTestBoard try begin 
                  InitTestBoard try 2 
                  InitTestBoard try end 
                  CGUI::InitDistance 
                  CGUI::InitCalibration 
                  CGUI::InitMotor 
                  main gui = 0x55b88df72d40
                  main cont = 0x55b88e483610
                  CThreadController gui = 0x55b88df72d40
                  CThreadController cont = 0x55b88e483610
                  CGUI::SetController controller = 0x55b88df8dd00
                  CControls::SetController begin 
                  CThreadController::startThreads begin
                  CThreadController::startThreads m_controls = 0x55b88e483610
                  CThreadController::startThreads m_gui = 0x55b88df72d40
                  CThreadController::startThreads this = 0x55b88df8dd00
                  CThreadController::startThreads m_controls = 0x55b88e483610
                  CThreadController::startThreads m_gui = 0x55b88df72d40
                  CThreadController::startThreads() end
                  CThreadController::ShowPointers m_controls = 0x55b88e483610
                  CThreadController::ShowPointers m_gui = 0x55b88df72d40
                  Btn_motor_update_Clicked begin 
                  CGUI::Btn_motor_update_Clicked pin = 12
                  CControls::SetNumPinPerBoard this = 0x55b88e483610
                  CControls::SetNumPinPerBoard m_threadcontroller = 0x55b88df8dd00
                  CControls::SetNumPinPerBoard n = 12
                  CGUI::Btn_motor_update_Clicked step = 4
                  CControls::SetStepMtrPst this = 0x55b88e483610
                  CControls::SetStepMtrPst m_threadcontroller = 0x55b88df8dd00
                  CControls::SetStepMtrPst n = 4
                  CControls::SetStepMtrPst m_iStepMtrPst = 4
                  CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x55b88df8dd00
                  CThreadController::SetNumMotorPos this = 0x55b88df8dd00
                  CThreadController::SetNumMotorPos m_controls = 0x55b88e6bd590
                  CThreadController::SetNumMotorPos m_gui = 0x55b8800000ef
                  CControls::SetNumMotorPos begin 
                  CControls::SetNumMotorPos this = 0x55b88e6bd590
                  CControls::SetNumMotorPos m_threadcontroller = 0x7fe7fc8aa668
                  CControls::SetNumMotorPos m_iStepMtrPst = -11711155
                  CMotor::SetNumMotorPos begin 
                  num = -11711155
                  error: CMotor.SetNumMotorPos() 
                  Btn_motor_update_Clicked end 
                  Press <RETURN> to close this window...
                  

                  correct CThreadController points to wrong CControls points back to wrong CThreadControlls

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    micha_eleric
                    wrote on last edited by
                    #10

                    change of pointers occur between

                    void CThreadController::startThreads()
                    

                    and

                    void CGUI::Btn_motor_update_Clicked()
                    

                    from what i can find

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      micha_eleric
                      wrote on last edited by micha_eleric
                      #11
                      __name__
                      CThreadController::CThreadController  () 
                      main threcon = 0x561d71086500
                      CGUI::CGUI 
                      CGUI::InitTestBoard 
                      InitTestBoard try begin 
                      InitTestBoard try 2 
                      InitTestBoard try end 
                      CGUI::InitDistance 
                      CGUI::InitCalibration 
                      CGUI::InitMotor 
                      main gui = 0x561d710809a0
                      CControls::Constructor 
                      main cont = 0x561d71590fd0
                      CThreadController gui = 0x561d710809a0
                      CThreadController cont = 0x561d71590fd0
                      CGUI::SetController controller = 0x561d71086500
                      CControls::SetController begin 
                      CThreadController::startThreads begin
                      CThreadController::startThreads m_controls = 0x561d71590fd0
                      CThreadController::startThreads m_gui = 0x561d710809a0
                      CThreadController::startThreads this = 0x561d71086500
                      CThreadController::startThreads m_controls = 0x561d71590fd0
                      CThreadController::startThreads m_gui = 0x561d710809a0
                      CThreadController::startThreads() end
                      CThreadController::ShowPointers m_controls = 0x561d71590fd0
                      CThreadController::ShowPointers m_gui = 0x561d710809a0
                      Btn_motor_update_Clicked begin 
                      CThreadController::ShowPointers m_controls = 0x561d00000021
                      CThreadController::ShowPointers m_gui = 0x561d7172ae70
                      CGUI::Btn_motor_update_Clicked pin = 12
                      CControls::SetNumPinPerBoard this = 0x561d71590fd0
                      CControls::SetNumPinPerBoard m_threadcontroller = 0x561d71086500
                      CControls::SetNumPinPerBoard n = 12
                      CThreadController::ShowPointers m_controls = 0x561d00000021
                      CThreadController::ShowPointers m_gui = 0x561d7172ae70
                      CGUI::Btn_motor_update_Clicked step = 4
                      CControls::SetStepMtrPst this = 0x561d71590fd0
                      CControls::SetStepMtrPst m_threadcontroller = 0x561d71086500
                      CControls::SetStepMtrPst n = 4
                      CControls::SetStepMtrPst m_iStepMtrPst = 4
                      CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x561d71086500
                      CThreadController::SetNumMotorPos this = 0x561d71086500
                      CThreadController::SetNumMotorPos m_controls = 0x561d00000021
                      CThreadController::SetNumMotorPos m_gui = 0x561d7172ae70
                      CControls::SetNumMotorPos begin 
                      CControls::SetNumMotorPos this = 0x561d00000021
                      Press <RETURN> to close this window...
                      

                      from std::cout output, it is clear the my code in main calls

                      threcon->startThreads();
                      

                      at the end of

                      void CThreadController::startThreads()
                      

                      the only 3 pointers my code creates/calls constructors, are what they are suppose to be.
                      next

                          threcon->ShowPointers();
                          gui->show();
                          return app.exec();
                      

                      then button is pushed, calling

                      void CGUI::Btn_BoardUpdate_Clicked()
                      

                      which, without calling any constructors, there are 3 new pointers created out of thin air.
                      what/where/why are the 3 new pointers coming from?
                      only possible answers i come up with:
                      does qt create, create pointers that do not call constructors?
                      when

                      connect(m_gui, &CNC::CGUI::emitRun, m_controls, &CNC::CControls::Run);
                      

                      does it create a duplicate pointers, which does not call constructors?

                      dont know what else could be happening.
                      if i reset the pointers in CThreadController, would whatever created new pointers, without calling a constructor, do it again. would i have to reset the pointers, every time a button is clicked?

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        micha_eleric
                        wrote on last edited by
                        #12

                        i tried a copy constructor, but it was not called

                        1 Reply Last reply
                        0
                        • M micha_eleric

                          @Christian-Ehrlicher said in pointer changing, without using anything in code:

                          @micha_eleric said in pointer changing, without using anything in code:

                          where and why is class data m_controls and m_gui changing in class CThreadController?

                          Provide a minimal, compilable example instead posting the whole question over and over without any real information.

                          i assume the minimum would be no code, since i can not find anything in my code to create the error. i posted everything of my code, where the error showed up. i keep adding more std::cout, trying to figure out between my code and my code it is happening.

                          Paul ColbyP Offline
                          Paul ColbyP Offline
                          Paul Colby
                          wrote on last edited by
                          #13

                          @micha_eleric said in pointer changing, without using anything in code:

                          i assume the minimum would be no code, since i can not find anything in my code to create the error.

                          Your assumption is very likely wrong. The thing is, with errors like this, it is very commonly the case that code elsewhere in your application has a memory error, but that the effect of that error is not visible until later (eg an earlier memory error could have overwritten your code segement, so your code no longer matches what you're reading in your editor). In other words, the bug might be nowhere near the crash (or pointer change) as far as lines of code goes.

                          There's a couple of approaches I've found to work in cases like this:

                          1. use a static analysis tool, like cppcheck (it's not going to pick up subtle things, but its so quick and easy to start with).
                          2. use a memory fencing tool, like valgrind
                          3. slowly remove as much code as possible, including (especially) code elsewhere that you assume couldn't possibly be related to this area of the code (I've been surprised plenty of times ;)

                          In particular, the exercise of cutting it down to "a minimal, compilable example", as @Christian-Ehrlicher suggested, will effectively force you to do #3 anyway, and often you'll discover the bug in that process, before you even get to posting the minimal example. But if you do get it down to a minimal compilable example, do share it! :D

                          Good luck!

                          1 Reply Last reply
                          2
                          • M Offline
                            M Offline
                            micha_eleric
                            wrote on last edited by micha_eleric
                            #14

                            well, if i comment out

                            m_controls->start();
                            

                            in

                            // function
                                void CThreadController::startThreads()
                                {
                                    m_controls->start();
                                }
                            

                            then the pointers do not change

                            start();
                            

                            is not my code.

                            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
                            • Unsolved