Input Type always set to `Assembly` on startup
federicovilla55 opened this issue · comments
I have noticed that each time I open a C
file in the Ripes GUI, after I save it and open it again, the same file appears in the Source Code section of the Editor tab, but the Input Type is always set to Assembly
.
The Ripes.config file, which saves the settings of Ripes, contains the parameter input_type
which stores an integer representing an element of the enumeration:
Lines 17 to 28 in 8780873
When I close the simulator with a C
file open in the editor tab, the field input_type = 1
is saved in the Ripes.config, indicating that the last opened file (whose source code is in the sourcecode
field of the Ripes.config file) was a C
file.
The problem is the next time Ripes is opened, that value is changed in input_type = 0
, which means that the file is always considered an Assembly
.
Looking at the code, the option input_type
is modified by the method EditTab::sourceTypeChanged()
and is set as follows:
Lines 255 to 276 in 8780873
So when opening the simulator the input type is set as default as m_ui->setCInput
has not been checked yet.
In the EditTab constructor before the m_ui
are toggled the following methods are called:
Lines 112 to 113 in 8780873
Those methods (that have a direct or indirect call to the method sourceTypeChanged()
) change the input type to Assembly
.
I suppose that those methods should not modify the input type, as it should be done in the constructor a few lines after:
Lines 127 to 139 in 8780873
My proposal for the problem:
- Move the
switch
to set the input type in the line following the statement to set the source code in the editor:
EditTab::EditTab(QToolBar *toolbar, QWidget *parent){
// ...
m_ui->codeEditor->document()->setPlainText(
RipesSettings::value(RIPES_SETTING_SOURCECODE).toString());
switch (RipesSettings::value(RIPES_SETTING_INPUT_TYPE).toInt()) {
case SourceType::Assembly: {
m_ui->setAssemblyInput->toggle();
break;
}
case SourceType::C: {
m_ui->setCInput->toggle();
break;
}
default:
break;
}
// ...
}