File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ ProjectLoader::ProjectLoader(QObject *parent) :
4343
4444ProjectLoader::~ProjectLoader ()
4545{
46+  m_stopLoading = true ;
47+ 
4648 if  (m_loadThread.isRunning ())
4749 m_loadThread.waitForFinished ();
4850
@@ -88,6 +90,7 @@ void ProjectLoader::setFileName(const QString &newFileName)
8890 emit loadStatusChanged ();
8991 emit fileNameChanged ();
9092
93+  m_stopLoading = false ;
9194 m_loadThread = QtConcurrent::run (&callLoad, this );
9295}
9396
@@ -193,7 +196,8 @@ void ProjectLoader::load()
193196
194197 m_sprites.clear ();
195198
196-  if  (!m_engine) {
199+  if  (!m_engine || m_stopLoading) {
200+  m_engineMutex.unlock ();
197201 emit fileNameChanged ();
198202 emit loadStatusChanged ();
199203 emit loadingFinished ();
@@ -226,6 +230,16 @@ void ProjectLoader::load()
226230 }
227231 }
228232
233+  if  (m_stopLoading) {
234+  m_engineMutex.unlock ();
235+  emit fileNameChanged ();
236+  emit loadStatusChanged ();
237+  emit loadingFinished ();
238+  emit engineChanged ();
239+  emit spritesChanged ();
240+  return ;
241+  }
242+ 
229243 //  Run event loop
230244 m_engine->setSpriteFencingEnabled (false );
231245
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ class ProjectLoader : public QObject
123123 bool  m_eventLoopEnabled = true ;
124124 std::atomic<unsigned  int > m_downloadedAssets = 0 ;
125125 std::atomic<unsigned  int > m_assetCount = 0 ;
126+  std::atomic<bool > m_stopLoading = false ;
126127};
127128
128129} //  namespace scratchcppgui
                         You can’t perform that action at this time. 
           
                  
0 commit comments