Skip to content

Commit 3e9947d

Browse files
committed
Fixed a recursive call to the async::processMessages
1 parent ada22d1 commit 3e9947d

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

src/framework/audio/engine/internal/export/soundtrackwriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Ret SoundTrackWriter::generateAudioData()
163163

164164
//! NOTE It is necessary for cancellation to work
165165
//! and for information about the audio signal to be transmitted.
166-
async::processMessages(thisThId);
166+
//async::processMessages(thisThId);
167167
rpcChannel()->process();
168168
}
169169

src/framework/audio/engine/internal/synthesizers/fluidsynth/fluidsynth.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ using namespace muse::audio;
3737
using namespace muse::audio::synth;
3838
using namespace muse::mpe;
3939

40+
static constexpr bool FLUID_DEBUG = false;
41+
4042
static constexpr double FLUID_GLOBAL_VOLUME_GAIN = 4.8;
4143
static constexpr int DEFAULT_MIDI_VOLUME = 100;
4244
static constexpr msecs_t MIN_NOTE_LENGTH = 10;
@@ -90,7 +92,9 @@ Ret FluidSynth::init(const OutputSpec& spec)
9092
LOGI() << message;
9193
} break;
9294
case FLUID_DBG: {
93-
LOGD() << message;
95+
if (FLUID_DEBUG) {
96+
LOGD() << message;
97+
}
9498
} break;
9599
}
96100

src/framework/global/thirdparty/kors_async/async/async.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Async
112112
m_queues.push_back(d);
113113

114114
d->queue.port2()->onMessage([d](const CallMsg& m) {
115+
assert(m.func && "m.func is nullptr");
115116
if (m.receiver) {
116117
if (d->isConnected(m.receiver)) {
117118
m.func->call(nullptr);
@@ -135,7 +136,10 @@ class Async
135136
{
136137
Call func;
137138
Func(const Call& f = nullptr)
138-
: func(f) {}
139+
: func(f)
140+
{
141+
assert(func && "callback is nullptr");
142+
}
139143

140144
void call(const void*) override
141145
{

src/framework/global/thirdparty/kors_async/async/internal/rpcqueue.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class RpcPort
7474
std::vector<T> m_buffer;
7575
std::queue<T> m_pending;
7676
std::function<void(const T&)> m_handler;
77+
bool m_isProcessing = false;
7778

7879
public:
7980

@@ -94,6 +95,9 @@ class RpcPort
9495

9596
assert(m_connPort);
9697

98+
assert(!m_isProcessing && "Recursive processing of messages is not allowed");
99+
m_isProcessing = true;
100+
97101
// receive messages
98102
m_buffer.clear();
99103
bool ok = m_connPort->m_queue.tryPopAll(m_buffer);
@@ -102,6 +106,8 @@ class RpcPort
102106
m_handler(item);
103107
}
104108
}
109+
110+
m_isProcessing = false;
105111
}
106112

107113
size_t countToSend() const

src/project/qml/MuseScore/Project/internal/Export/exportdialogmodel.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <algorithm>
2525

2626
#include <QItemSelectionModel>
27+
#include <QTimer>
2728

2829
#include "async/async.h"
2930
#include "translation.h"
@@ -425,7 +426,11 @@ bool ExportDialogModel::exportScores()
425426
shouldDestinationFolderBeOpenedOnExport() };
426427

427428
std::shared_ptr<IExportProjectScenario> scenario = exportProjectScenario();
428-
async::Async::call(nullptr, [scenario, params]() {
429+
430+
//! NOTE We can't use Async here
431+
// because the async::processMessgaes is called deep within the functions,
432+
// and this can't be done in Async's callback.
433+
QTimer::singleShot(0, [scenario, params]() {
429434
scenario->exportScores(params.notations, params.exportPath, params.selectedUnitType, params.openFolderOnExport);
430435
});
431436

0 commit comments

Comments
 (0)