Delete lockfile at shutdown on linux and mac.

Passing lockfile on mac by sending message .
This commit is contained in:
David Kocik 2021-02-17 09:38:00 +01:00
parent 19f849a6d9
commit 15d9751919
4 changed files with 89 additions and 22 deletions

View file

@ -15,6 +15,8 @@
//NSString *nsver = @"OtherPrusaSlicerInstanceMessage" + version_hash;
NSString *nsver = [NSString stringWithFormat: @"%@%@", @"OtherPrusaSlicerInstanceMessage", version_hash];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(message_update:) name:nsver object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
NSString *nsver2 = [NSString stringWithFormat: @"%@%@", @"OtherPrusaSlicerInstanceClosing", version_hash];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(closing_update:) name:nsver2 object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
}
-(void)message_update:(NSNotification *)msg
@ -24,6 +26,13 @@
Slic3r::GUI::wxGetApp().other_instance_message_handler()->handle_message(std::string([msg.userInfo[@"data"] UTF8String]));
}
-(void)closing_update:(NSNotification *)msg
{
//[self bring_forward];
//pass message
Slic3r::GUI::wxGetApp().other_instance_message_handler()->handle_message_other_closed();
}
-(void) bring_forward
{
//demiaturize all windows
@ -51,6 +60,15 @@ void send_message_mac(const std::string &msg, const std::string &version)
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:notifname object:nil userInfo:[NSDictionary dictionaryWithObject:nsmsg forKey:@"data"] deliverImmediately:YES];
}
void send_message_mac_closing(const std::string &msg, const std::string &version)
{
NSString *nsmsg = [NSString stringWithCString:msg.c_str() encoding:[NSString defaultCStringEncoding]];
//NSString *nsver = @"OtherPrusaSlicerInstanceMessage" + [NSString stringWithCString:version.c_str() encoding:[NSString defaultCStringEncoding]];
NSString *nsver = [NSString stringWithCString:version.c_str() encoding:[NSString defaultCStringEncoding]];
NSString *notifname = [NSString stringWithFormat: @"%@%@", @"OtherPrusaSlicerInstanceClosing", nsver];
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:notifname object:nil userInfo:[NSDictionary dictionaryWithObject:nsmsg forKey:@"data"] deliverImmediately:YES];
}
namespace GUI {
void OtherInstanceMessageHandler::register_for_messages(const std::string &version_hash)
{