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) :
43
43
44
44
ProjectLoader::~ProjectLoader ()
45
45
{
46
+ m_stopLoading = true ;
47
+
46
48
if (m_loadThread.isRunning ())
47
49
m_loadThread.waitForFinished ();
48
50
@@ -88,6 +90,7 @@ void ProjectLoader::setFileName(const QString &newFileName)
88
90
emit loadStatusChanged ();
89
91
emit fileNameChanged ();
90
92
93
+ m_stopLoading = false ;
91
94
m_loadThread = QtConcurrent::run (&callLoad, this );
92
95
}
93
96
@@ -193,7 +196,8 @@ void ProjectLoader::load()
193
196
194
197
m_sprites.clear ();
195
198
196
- if (!m_engine) {
199
+ if (!m_engine || m_stopLoading) {
200
+ m_engineMutex.unlock ();
197
201
emit fileNameChanged ();
198
202
emit loadStatusChanged ();
199
203
emit loadingFinished ();
@@ -226,6 +230,16 @@ void ProjectLoader::load()
226
230
}
227
231
}
228
232
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
+
229
243
// Run event loop
230
244
m_engine->setSpriteFencingEnabled (false );
231
245
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ class ProjectLoader : public QObject
123
123
bool m_eventLoopEnabled = true ;
124
124
std::atomic<unsigned int > m_downloadedAssets = 0 ;
125
125
std::atomic<unsigned int > m_assetCount = 0 ;
126
+ std::atomic<bool > m_stopLoading = false ;
126
127
};
127
128
128
129
} // namespace scratchcppgui
You can’t perform that action at this time.
0 commit comments