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 0f48541
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 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

0 comments on commit 0f48541

Please sign in to comment.