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. Crash after try to validate pointer
Forum Updated to NodeBB v4.3 + New Features

Crash after try to validate pointer

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 298 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.
  • B Offline
    B Offline
    BushyAxis793
    wrote on last edited by BushyAxis793
    #1

    Hello. I 'm working on app which I will use to calculate some type of operations. I have dialog which is connected via signal/slot with his parent dialog. I have a lot of QWidgets on this dialog which are pointers. Some of them I initialise when I choose correct type of workplace. When I decide to choose for example "Cooperation" workplace, other QWidgets are initialise to nullptr. When I put some values to controls and click add button, the signal is emit and all data from all controls should go to the parent. However I have a problem with some widgets. When the object is not initialise (set to nullptr) I have a validation for this case. Below is the code of my signal which I call on add button:

    void SimplyOperationDataDialog::on_addButton_pressed()
    {
        if(IsRequiredDataInserted())
        {
            emit SendOperationData(GetWorkplaceName(),GetOperationName(),GetToolsQuantity(),GetOperationTime(),GetOperationDescription(),
                                   GetPreparationAndCompletionTime(),GetWorkplaceNumber(),GetWorkplaceCost(),GetUnitTime(),
                                   GetOperationClampingNumber(), GetOperationClampingData(),
                                    //Cooperation
                                   GetCooperationRateCurrency(),GetCooperationRateCurrencyCost(),
                                   GetCooperationUnitCurrency(),GetCooperationUnitCurrencyCost(),
                                   GetCooperationTotalCost(),
                                   //QualityControl
                                   GetQualityControlsMeasurementType(),
                                   GetQualityControlMeasurementTime(),
                                   GetQualityControlMeasurementEquipmentStatus(),
                                   //Marker
                                   GetMarkerFile(),
                                   GetMarkerTime(),
                                   //IronWorks
                                   //Assembly
                                   GetIronworksAssemblyType(),
                                   GetIronworksAssemblyTime(),
                                   //Packing
                                   GetIronworksPackingBoxType(),
                                   GetIronworksPackingBoxMaxQuantity(),
                                   GetIronworksPackingMaterial(),
                                   GetIronworksPackingTime(),
                                   //Drilling
                                   GetIronworksDrillingDrill(),
                                   GetIronworksDrillingMachine(),
                                   GetIronworksDrillingTime(),
                                   //Polishing
                                   GetIronworksPolishingAgent(),
                                   GetIronworksPolishingMaterial(),
                                   GetIronworksPolishingTime(),
                                   //Trovalization
                                   GetIronworksTrovalizationType(),
                                   GetIronworksTrovalizationAbrasiveAgent(),
                                   GetIronworksTrovalizationTime(),
                                   GetIronworksTrovalizationPartQuantity(),
                                   //Washing
                                   GetIronworksWashingAgent(),
                                   GetIronworksWashingTime(),
                                   //Conservation
                                   GetIronworksConservationAgent(),
                                   GetIronworksConservationTime());
    
            CleanControls();
    
            this->~SimplyOperationDataDialog();
        }
    }
    

    I have a problem with tho Getters: GetIronworksTrovalizationAbrasiveAgent() and GetIronworksTrovalizationTime(). During debugging my app crashes on one of them with error:
    d22f167d-c743-4d8a-8006-70315e792160-image.png

    Below is the code which I use in both Getters:

    QString SimplyOperationDataDialog::GetIronworksTrovalizationAbrasiveAgent() const
    {
        if(ironworksTrovalizationAbrasiveAgentComboBox != nullptr)
        {
            if(ironworksTrovalizationAbrasiveAgentComboBox->isEnabled())
            {
                return ironworksTrovalizationAbrasiveAgentComboBox->currentText();
            }
            else
            {
                return STR_EMPTY;
            }
        }
        else
        {
            return STR_EMPTY;
        }
    }
    
    double SimplyOperationDataDialog::GetIronworksTrovalizationTime() const
    {
        if(ironworksTrovalizationTimeLineEdit!= nullptr)
        {
            if(ironworksTrovalizationTimeLineEdit->isEnabled())
            {
                return ironworksTrovalizationTimeLineEdit->text().toDouble();
            }
            else
            {
                return DBL_NULL;
            }
        }
        else
        {
            return DBL_NULL;
        }
    
    }
    

    Both widget are set in constructor for nullptr. When I choose exact workplace they are initialise (new QCombobox()) or not.

    So my question is: Why I got this error? Why I got error with attribute WS_Disabled? How can I solve it? Many thanks for any help.

    Have a good day
    BushyAxis793

    JonBJ JoeCFDJ 2 Replies Last reply
    0
    • B Offline
      B Offline
      BushyAxis793
      wrote on last edited by
      #4

      Thanks everyone for help! I found a solution. I didn't check all pointers. Now it works!

      1 Reply Last reply
      0
      • B BushyAxis793

        Hello. I 'm working on app which I will use to calculate some type of operations. I have dialog which is connected via signal/slot with his parent dialog. I have a lot of QWidgets on this dialog which are pointers. Some of them I initialise when I choose correct type of workplace. When I decide to choose for example "Cooperation" workplace, other QWidgets are initialise to nullptr. When I put some values to controls and click add button, the signal is emit and all data from all controls should go to the parent. However I have a problem with some widgets. When the object is not initialise (set to nullptr) I have a validation for this case. Below is the code of my signal which I call on add button:

        void SimplyOperationDataDialog::on_addButton_pressed()
        {
            if(IsRequiredDataInserted())
            {
                emit SendOperationData(GetWorkplaceName(),GetOperationName(),GetToolsQuantity(),GetOperationTime(),GetOperationDescription(),
                                       GetPreparationAndCompletionTime(),GetWorkplaceNumber(),GetWorkplaceCost(),GetUnitTime(),
                                       GetOperationClampingNumber(), GetOperationClampingData(),
                                        //Cooperation
                                       GetCooperationRateCurrency(),GetCooperationRateCurrencyCost(),
                                       GetCooperationUnitCurrency(),GetCooperationUnitCurrencyCost(),
                                       GetCooperationTotalCost(),
                                       //QualityControl
                                       GetQualityControlsMeasurementType(),
                                       GetQualityControlMeasurementTime(),
                                       GetQualityControlMeasurementEquipmentStatus(),
                                       //Marker
                                       GetMarkerFile(),
                                       GetMarkerTime(),
                                       //IronWorks
                                       //Assembly
                                       GetIronworksAssemblyType(),
                                       GetIronworksAssemblyTime(),
                                       //Packing
                                       GetIronworksPackingBoxType(),
                                       GetIronworksPackingBoxMaxQuantity(),
                                       GetIronworksPackingMaterial(),
                                       GetIronworksPackingTime(),
                                       //Drilling
                                       GetIronworksDrillingDrill(),
                                       GetIronworksDrillingMachine(),
                                       GetIronworksDrillingTime(),
                                       //Polishing
                                       GetIronworksPolishingAgent(),
                                       GetIronworksPolishingMaterial(),
                                       GetIronworksPolishingTime(),
                                       //Trovalization
                                       GetIronworksTrovalizationType(),
                                       GetIronworksTrovalizationAbrasiveAgent(),
                                       GetIronworksTrovalizationTime(),
                                       GetIronworksTrovalizationPartQuantity(),
                                       //Washing
                                       GetIronworksWashingAgent(),
                                       GetIronworksWashingTime(),
                                       //Conservation
                                       GetIronworksConservationAgent(),
                                       GetIronworksConservationTime());
        
                CleanControls();
        
                this->~SimplyOperationDataDialog();
            }
        }
        

        I have a problem with tho Getters: GetIronworksTrovalizationAbrasiveAgent() and GetIronworksTrovalizationTime(). During debugging my app crashes on one of them with error:
        d22f167d-c743-4d8a-8006-70315e792160-image.png

        Below is the code which I use in both Getters:

        QString SimplyOperationDataDialog::GetIronworksTrovalizationAbrasiveAgent() const
        {
            if(ironworksTrovalizationAbrasiveAgentComboBox != nullptr)
            {
                if(ironworksTrovalizationAbrasiveAgentComboBox->isEnabled())
                {
                    return ironworksTrovalizationAbrasiveAgentComboBox->currentText();
                }
                else
                {
                    return STR_EMPTY;
                }
            }
            else
            {
                return STR_EMPTY;
            }
        }
        
        double SimplyOperationDataDialog::GetIronworksTrovalizationTime() const
        {
            if(ironworksTrovalizationTimeLineEdit!= nullptr)
            {
                if(ironworksTrovalizationTimeLineEdit->isEnabled())
                {
                    return ironworksTrovalizationTimeLineEdit->text().toDouble();
                }
                else
                {
                    return DBL_NULL;
                }
            }
            else
            {
                return DBL_NULL;
            }
        
        }
        

        Both widget are set in constructor for nullptr. When I choose exact workplace they are initialise (new QCombobox()) or not.

        So my question is: Why I got this error? Why I got error with attribute WS_Disabled? How can I solve it? Many thanks for any help.

        Have a good day
        BushyAxis793

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #2

        @BushyAxis793 said in Crash after try to validate pointer:

        During debugging my app crashes on one of them with error:

        I don't actually see any crash. If/when it does crash, we need the stack trace window in the debugger.

        It's your job to initialise all pointers to nullptr if necessary, and ensure what they point to is valid.

        Once you have this working you might like to rethink your signal parameters. Passing that many is not a good idea.

        1 Reply Last reply
        1
        • B BushyAxis793

          Hello. I 'm working on app which I will use to calculate some type of operations. I have dialog which is connected via signal/slot with his parent dialog. I have a lot of QWidgets on this dialog which are pointers. Some of them I initialise when I choose correct type of workplace. When I decide to choose for example "Cooperation" workplace, other QWidgets are initialise to nullptr. When I put some values to controls and click add button, the signal is emit and all data from all controls should go to the parent. However I have a problem with some widgets. When the object is not initialise (set to nullptr) I have a validation for this case. Below is the code of my signal which I call on add button:

          void SimplyOperationDataDialog::on_addButton_pressed()
          {
              if(IsRequiredDataInserted())
              {
                  emit SendOperationData(GetWorkplaceName(),GetOperationName(),GetToolsQuantity(),GetOperationTime(),GetOperationDescription(),
                                         GetPreparationAndCompletionTime(),GetWorkplaceNumber(),GetWorkplaceCost(),GetUnitTime(),
                                         GetOperationClampingNumber(), GetOperationClampingData(),
                                          //Cooperation
                                         GetCooperationRateCurrency(),GetCooperationRateCurrencyCost(),
                                         GetCooperationUnitCurrency(),GetCooperationUnitCurrencyCost(),
                                         GetCooperationTotalCost(),
                                         //QualityControl
                                         GetQualityControlsMeasurementType(),
                                         GetQualityControlMeasurementTime(),
                                         GetQualityControlMeasurementEquipmentStatus(),
                                         //Marker
                                         GetMarkerFile(),
                                         GetMarkerTime(),
                                         //IronWorks
                                         //Assembly
                                         GetIronworksAssemblyType(),
                                         GetIronworksAssemblyTime(),
                                         //Packing
                                         GetIronworksPackingBoxType(),
                                         GetIronworksPackingBoxMaxQuantity(),
                                         GetIronworksPackingMaterial(),
                                         GetIronworksPackingTime(),
                                         //Drilling
                                         GetIronworksDrillingDrill(),
                                         GetIronworksDrillingMachine(),
                                         GetIronworksDrillingTime(),
                                         //Polishing
                                         GetIronworksPolishingAgent(),
                                         GetIronworksPolishingMaterial(),
                                         GetIronworksPolishingTime(),
                                         //Trovalization
                                         GetIronworksTrovalizationType(),
                                         GetIronworksTrovalizationAbrasiveAgent(),
                                         GetIronworksTrovalizationTime(),
                                         GetIronworksTrovalizationPartQuantity(),
                                         //Washing
                                         GetIronworksWashingAgent(),
                                         GetIronworksWashingTime(),
                                         //Conservation
                                         GetIronworksConservationAgent(),
                                         GetIronworksConservationTime());
          
                  CleanControls();
          
                  this->~SimplyOperationDataDialog();
              }
          }
          

          I have a problem with tho Getters: GetIronworksTrovalizationAbrasiveAgent() and GetIronworksTrovalizationTime(). During debugging my app crashes on one of them with error:
          d22f167d-c743-4d8a-8006-70315e792160-image.png

          Below is the code which I use in both Getters:

          QString SimplyOperationDataDialog::GetIronworksTrovalizationAbrasiveAgent() const
          {
              if(ironworksTrovalizationAbrasiveAgentComboBox != nullptr)
              {
                  if(ironworksTrovalizationAbrasiveAgentComboBox->isEnabled())
                  {
                      return ironworksTrovalizationAbrasiveAgentComboBox->currentText();
                  }
                  else
                  {
                      return STR_EMPTY;
                  }
              }
              else
              {
                  return STR_EMPTY;
              }
          }
          
          double SimplyOperationDataDialog::GetIronworksTrovalizationTime() const
          {
              if(ironworksTrovalizationTimeLineEdit!= nullptr)
              {
                  if(ironworksTrovalizationTimeLineEdit->isEnabled())
                  {
                      return ironworksTrovalizationTimeLineEdit->text().toDouble();
                  }
                  else
                  {
                      return DBL_NULL;
                  }
              }
              else
              {
                  return DBL_NULL;
              }
          
          }
          

          Both widget are set in constructor for nullptr. When I choose exact workplace they are initialise (new QCombobox()) or not.

          So my question is: Why I got this error? Why I got error with attribute WS_Disabled? How can I solve it? Many thanks for any help.

          Have a good day
          BushyAxis793

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #3

          @BushyAxis793 said in Crash after try to validate pointer:

          this->~SimplyOperationDataDialog();

          call destructor directly?

          this->~SimplyOperationDataDialog();
          
          1 Reply Last reply
          2
          • B Offline
            B Offline
            BushyAxis793
            wrote on last edited by
            #4

            Thanks everyone for help! I found a solution. I didn't check all pointers. Now it works!

            1 Reply Last reply
            0
            • B BushyAxis793 has marked this topic as solved on

            • Login

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