Skip to content

Commit

Permalink
Fix crash bug when saving source files for NXT
Browse files Browse the repository at this point in the history
  • Loading branch information
MinyazevR committed Jan 8, 2025
1 parent 92840bf commit ea22f09
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ NxtOsekCGeneratorPlugin::NxtOsekCGeneratorPlugin()
, mFlashRobotAction(new QAction(this))
, mUploadProgramAction(new QAction(this))
, mNxtToolsPresent(false)
, mMasterGenerator(nullptr)
, mCommunicator(utils::Singleton<communication::UsbRobotCommunicationThread>::instance())
{
initActions();
Expand Down Expand Up @@ -179,21 +178,24 @@ void NxtOsekCGeneratorPlugin::onUploadingComplete(bool success)

generatorBase::MasterGeneratorBase *NxtOsekCGeneratorPlugin::masterGenerator()
{
mMasterGenerator = new NxtOsekCMasterGenerator(*mRepo
return new NxtOsekCMasterGenerator(*mRepo
, *mMainWindowInterface->errorReporter()
, *mParserErrorReporter
, *mRobotModelManager
, *mTextLanguage
, mMainWindowInterface->activeDiagram()
, generatorName());
return mMasterGenerator;
}

void NxtOsekCGeneratorPlugin::regenerateExtraFiles(const QFileInfo &newFileInfo)
{
mMasterGenerator->initialize();
mMasterGenerator->setProjectDir(newFileInfo);
mMasterGenerator->generateOilAndMakeFiles();
// Static cast is possible and correct, but dynamic will be more flexible.
if (auto nxtGenerator = dynamic_cast<NxtOsekCMasterGenerator*>(masterGenerator())) {
QScopedPointer<NxtOsekCMasterGenerator> generator(nxtGenerator);
generator->initialize();
generator->setProjectDir(newFileInfo);
generator->generateOilAndMakeFiles();
}
}

void NxtOsekCGeneratorPlugin::flashRobot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ private slots:
bool mNxtToolsPresent { false };
/// Flasher object
QScopedPointer<NxtFlashTool> mFlashTool;

NxtOsekCMasterGenerator *mMasterGenerator;
const QSharedPointer<communication::UsbRobotCommunicationThread> mCommunicator;
};

Expand Down
8 changes: 4 additions & 4 deletions qrtranslations/fr/plugins/robots/nxtOsekCGenerator_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@
<translation>Génération (NXT OSEK C)</translation>
</message>
<message>
<location line="+52"/>
<location line="+129"/>
<location line="+51"/>
<location line="+132"/>
<source>NXT tools package is not installed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-82"/>
<location line="-85"/>
<source>Generate code</source>
<translation>Générer le code</translation>
</message>
Expand All @@ -196,7 +196,7 @@
<translation>Téléverser le programme sur le dispositif NXT</translation>
</message>
<message>
<location line="+50"/>
<location line="+53"/>
<source>flash.sh not found. Make sure it is present in QReal installation directory</source>
<translation>flash.sh n&apos;est pas trouvé. Assurez-vous qu&apos;il soit présent dans le repertoire de QReal</translation>
</message>
Expand Down
8 changes: 4 additions & 4 deletions qrtranslations/ru/plugins/robots/nxtOsekCGenerator_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@
<translation>Генерация (C)</translation>
</message>
<message>
<location line="+52"/>
<location line="+129"/>
<location line="+51"/>
<location line="+132"/>
<source>NXT tools package is not installed</source>
<translation>Пакет &quot;Инструменты NXT&quot; не установлен</translation>
</message>
<message>
<location line="-82"/>
<location line="-85"/>
<source>Generate code</source>
<translation>Генерировать код</translation>
</message>
Expand All @@ -200,7 +200,7 @@
<translation>Загрузить программу на устройство NXT</translation>
</message>
<message>
<location line="+50"/>
<location line="+53"/>
<source>flash.sh not found. Make sure it is present in QReal installation directory</source>
<translation>Не найден скрипт flash.sh. Убедитесь, что пакет nxt-tools установлен корректно</translation>
</message>
Expand Down

0 comments on commit ea22f09

Please sign in to comment.