Runtime error
-
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()
andsetProgressWizardBool()
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; }
-
Hi,
Why are you passing an int to change the value of a boolean ?
Can you post the complete code of your class ?
-
Hi,
Why are you passing an int to change the value of a boolean ?
Can you post the complete code of your class ?
@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)
-
@Circuits said in Runtime error:
presentationManager.settingsPresenter.setProgressWizardBool(1)
You are still passing an integer and not a boolean.
-
@Circuits said in Runtime error:
presentationManager.settingsPresenter.setProgressWizardBool(1)
You are still passing an integer and not a boolean.