File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ void ProjectLoader::clear()
251251 if (m_engine)
252252 m_engine->clear ();
253253
254+ m_oldEngine = m_engine;
254255 m_engine = nullptr ;
255256 emit engineChanged ();
256257}
@@ -280,12 +281,14 @@ void ProjectLoader::load()
280281 m_engine->setSpriteFencingEnabled (m_spriteFencing);
281282 m_engine->setGlobalVolume (m_mute ? 0 : 100 );
282283
283- m_engine->aboutToRender ().connect (&ProjectLoader::redraw, this );
284- m_engine->monitorAdded ().connect (&ProjectLoader::addMonitor, this );
285- m_engine->monitorRemoved ().connect (&ProjectLoader::removeMonitor, this );
284+ if (m_engine != m_oldEngine) {
285+ m_engine->aboutToRender ().connect (&ProjectLoader::redraw, this );
286+ m_engine->monitorAdded ().connect (&ProjectLoader::addMonitor, this );
287+ m_engine->monitorRemoved ().connect (&ProjectLoader::removeMonitor, this );
286288
287- m_engine->questionAsked ().connect ([this ](const std::string &question) { emit questionAsked (QString::fromStdString (question)); });
288- m_engine->questionAborted ().connect ([this ]() { emit questionAborted (); });
289+ m_engine->questionAsked ().connect ([this ](const std::string &question) { emit questionAsked (QString::fromStdString (question)); });
290+ m_engine->questionAborted ().connect ([this ]() { emit questionAborted (); });
291+ }
289292
290293 // Load targets
291294 const auto &targets = m_engine->targets ();
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ class ProjectLoader : public QObject
146146 libscratchcpp::Project m_project;
147147 bool m_running = false ;
148148 libscratchcpp::IEngine *m_engine = nullptr ;
149+ libscratchcpp::IEngine *m_oldEngine = nullptr ;
149150 QMutex m_engineMutex;
150151 bool m_loadStatus = false ;
151152 StageModel m_stage;
You can’t perform that action at this time.
0 commit comments