summaryrefslogtreecommitdiff
path: root/src/drumkitloader.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-04-25 21:43:48 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-04-25 21:43:48 +0200
commit3dcc42c508dd798b9034f77e6f83ec75e648936c (patch)
treec45c8d5bfb9ec3c4e7a0ebe8b3d8575434ea1cd7 /src/drumkitloader.cc
parent215bade4f4d5b590d03c12fc62f1a20e3fa59ef3 (diff)
Fix crash on 'load drumkit' while another drumkit is already loading.
Diffstat (limited to 'src/drumkitloader.cc')
-rw-r--r--src/drumkitloader.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc
index c997dfb..79d000a 100644
--- a/src/drumkitloader.cc
+++ b/src/drumkitloader.cc
@@ -36,6 +36,7 @@ DrumKitLoader::DrumKitLoader(DrumGizmo *dg)
drumgizmo = dg;
is_done = false;
quitit = false;
+ skipit = false;
}
DrumKitLoader::~DrumKitLoader()
@@ -52,6 +53,13 @@ void DrumKitLoader::stop()
wait_stop();
}
+void DrumKitLoader::skip()
+{
+ skipit = true;
+ semaphore.post();
+ skip_semaphore.wait();
+}
+
bool DrumKitLoader::isDone()
{
bool done;
@@ -74,8 +82,6 @@ void DrumKitLoader::loadKit(DrumKit *kit)
semaphore.post();
}
-
-
void DrumKitLoader::thread_main()
{
while(1) {
@@ -86,6 +92,12 @@ void DrumKitLoader::thread_main()
if(quitit) return;
+ if(skipit) {
+ skip_semaphore.post();
+ skipit = false;
+ continue;
+ }
+
unsigned int count = 0;
if(kit && !kit->isValid()) goto finish;
@@ -133,7 +145,7 @@ void DrumKitLoader::thread_main()
a++;
- if(quitit) return;
+ if(skipit) goto finish;
}
i++;