diff --git a/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.cpp b/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.cpp index e408cc20b2..cfe58cb83e 100644 --- a/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.cpp +++ b/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.cpp @@ -34,7 +34,6 @@ NxtOsekCGeneratorPlugin::NxtOsekCGeneratorPlugin() , mFlashRobotAction(new QAction(this)) , mUploadProgramAction(new QAction(this)) , mNxtToolsPresent(false) - , mMasterGenerator(nullptr) , mCommunicator(utils::Singleton::instance()) { initActions(); @@ -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(masterGenerator())) { + QScopedPointer generator(nxtGenerator); + generator->initialize(); + generator->setProjectDir(newFileInfo); + generator->generateOilAndMakeFiles(); + } } void NxtOsekCGeneratorPlugin::flashRobot() diff --git a/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.h b/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.h index b8e56e61d2..de32d029ef 100644 --- a/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.h +++ b/plugins/robots/generators/nxt/nxtOsekCGenerator/nxtOsekCGeneratorPlugin.h @@ -89,8 +89,6 @@ private slots: bool mNxtToolsPresent { false }; /// Flasher object QScopedPointer mFlashTool; - - NxtOsekCMasterGenerator *mMasterGenerator; const QSharedPointer mCommunicator; };