mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
single instance check
processing paths with whitespaces unified lock for all systems - wxInstanceChecker checking a messaging only for same binaries
This commit is contained in:
parent
ad1c6c29f4
commit
65a37ffaa1
10 changed files with 282 additions and 200 deletions
|
@ -9,10 +9,12 @@
|
|||
self = [super init];
|
||||
return self;
|
||||
}
|
||||
-(void)add_observer
|
||||
-(void)add_observer:(NSString *)version_hash
|
||||
{
|
||||
NSLog(@"adding observer");
|
||||
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(message_update:) name:@"OtherPrusaSlicerInstanceMessage" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
|
||||
//NSLog(@"adding observer");
|
||||
//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];
|
||||
}
|
||||
|
||||
-(void)message_update:(NSNotification *)msg
|
||||
|
@ -36,19 +38,22 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
void send_message_mac(const std::string msg)
|
||||
void send_message_mac(const std::string &msg, const std::string &version)
|
||||
{
|
||||
NSString *nsmsg = [NSString stringWithCString:msg.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
//NSLog(@"sending msg %@", nsmsg);
|
||||
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"OtherPrusaSlicerInstanceMessage" object:nil userInfo:[NSDictionary dictionaryWithObject:nsmsg forKey:@"data"] deliverImmediately:YES];
|
||||
//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: @"%@%@", @"OtherPrusaSlicerInstanceMessage", nsver];
|
||||
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:notifname object:nil userInfo:[NSDictionary dictionaryWithObject:nsmsg forKey:@"data"] deliverImmediately:YES];
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
void OtherInstanceMessageHandler::register_for_messages()
|
||||
void OtherInstanceMessageHandler::register_for_messages(const std::string &version_hash)
|
||||
{
|
||||
m_impl_osx = [[OtherInstanceMessageHandlerMac alloc] init];
|
||||
if(m_impl_osx) {
|
||||
[m_impl_osx add_observer];
|
||||
NSString *nsver = [NSString stringWithCString:version_hash.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
[m_impl_osx add_observer:nsver];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +64,7 @@ void OtherInstanceMessageHandler::unregister_for_messages()
|
|||
[m_impl_osx release];
|
||||
m_impl_osx = nullptr;
|
||||
} else {
|
||||
NSLog(@"unreegister not required");
|
||||
NSLog(@"warning: unregister instance InstanceCheck notifications not required");
|
||||
}
|
||||
}
|
||||
}//namespace GUI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue