Fix serial close behavior

This commit is contained in:
Lior Halphon 2022-02-25 14:29:21 +02:00
parent 8073e3d39e
commit 641f26e13e

View File

@ -453,7 +453,6 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency)
- (void) run - (void) run
{ {
assert(!master); assert(!master);
running = true;
[self preRun]; [self preRun];
if (slave) { if (slave) {
[slave preRun]; [slave preRun];
@ -532,6 +531,7 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency)
return; return;
} }
if (running) return; if (running) return;
running = true;
[[[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil] start]; [[[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil] start];
} }
@ -2065,6 +2065,7 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency)
bool wasRunning = self->running; bool wasRunning = self->running;
Document *partner = master ?: slave; Document *partner = master ?: slave;
if (partner) { if (partner) {
wasRunning |= partner->running;
[self stop]; [self stop];
partner->master = nil; partner->master = nil;
partner->slave = nil; partner->slave = nil;