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. Runtime error

Runtime error

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.4k 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by Circuits
    #1

    I recently changed the initialization of a member variable. Originally, the header had no constructor so I declared the variable on the fly in the declaration:

    private:
    bool m_progressWizardBool = false;
    

    no error here but then I went back later and created a constructor and declared it as such:

    public:
        SettingsPresenter()
        : m_progressWizardBool(false)
        {
    
        }
    ...
    private:
         bool m_progressWizardBool;
    

    after doing that I am now getting a runtime error:

    runtime error: load of value 190, which is not a valid value for type 'bool'
    

    any idea what I have done wrong? It might be helpful to know that the bool is being used in the QML like so:

    if(!settingValue.settingInvalid)
          {
            if(presentationManager.settingsPresenter.getProgressWizardBool() === false)
            {
              presentationManager.settingsPresenter.setProgressWizardBool(1)
            }
    ...
    

    where getProgressWizardBool() and setProgressWizardBool() are declared in the .cpp file for the header in question:

    void SettingsPresenter::setProgressWizardBool(int requestedValue)
    {
        if (m_progressWizardBool != requestedValue)
        {
          m_progressWizardBool = requestedValue;
          emit progressWizardBoolChanged();
        }
    }
    
    bool SettingsPresenter::getProgressWizardBool() const
    {
        return m_progressWizardBool;
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Why are you passing an int to change the value of a boolean ?

      Can you post the complete code of your class ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        Why are you passing an int to change the value of a boolean ?

        Can you post the complete code of your class ?

        C Offline
        C Offline
        Circuits
        wrote on last edited by
        #3

        @SGaist I posted something incorrectly in my first post. The error is actually coming from the .cpp file:

        SettingsPresenter.cpp:527:12: runtime error: load of value 190, which is not a valid value for type 'bool'
        SettingsPresenter.cpp:518:9: runtime error: load of value 190, which is not a valid value for type 'bool'
        

        I changed the argument to be of type bool as you suggested but the error persists.

        line 527: return m_progressWizardBool;
        line 518: if (m_progressWizardBool != requestedValue)
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Circuits said in Runtime error:

          presentationManager.settingsPresenter.setProgressWizardBool(1)

          You are still passing an integer and not a boolean.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply
          0
          • SGaistS SGaist

            @Circuits said in Runtime error:

            presentationManager.settingsPresenter.setProgressWizardBool(1)

            You are still passing an integer and not a boolean.

            C Offline
            C Offline
            Circuits
            wrote on last edited by
            #5

            @SGaist OH sorry I should have mentioned, I changed that as well.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Circuits
              wrote on last edited by
              #6

              I understand now, the mistake I made. I should have defined in the header:

              public:
                  SettingsPresenter();
              ...
              private:
              m_progressWizardBool;
              

              and then in the .cpp file:

              SettingsPresenter::SettingsPresenter()
                : m_progressWizardBool(false)
              
              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