From 5db3950424f19520d0f1b13f7d7647dab01adf80 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Wed, 29 Nov 2017 14:37:13 +0100 Subject: [PATCH] fixed issue with wrong clear timeout when pasting was done inside the clear timeout --- MacPass/MPPasteBoardController.m | 5 ++++- MacPass/MPPluginConstants.h | 13 +++++++++++++ MacPass/MPPluginConstants.m | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 MacPass/MPPluginConstants.h create mode 100644 MacPass/MPPluginConstants.m diff --git a/MacPass/MPPasteBoardController.m b/MacPass/MPPasteBoardController.m index 2b0a44d0..38b33123 100644 --- a/MacPass/MPPasteBoardController.m +++ b/MacPass/MPPasteBoardController.m @@ -96,6 +96,9 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas [self copyObjectsWithoutTimeout:objects]; if(self.clearTimeout != 0) { [NSNotificationCenter.defaultCenter postNotificationName:MPPasteBoardControllerDidCopyObjects object:self]; + /* cancel old timer */ + [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_clearPasteboardContents) object:nil]; + /* setup new timer */ [self performSelector:@selector(_clearPasteboardContents) withObject:nil afterDelay:self.clearTimeout]; } } @@ -140,7 +143,7 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas - (void)_clearPasteboardContents { /* Only clear stuff we might have put there */ if(!self.isEmpty) { - [[NSPasteboard generalPasteboard] clearContents]; + [NSPasteboard.generalPasteboard clearContents]; [NSNotificationCenter.defaultCenter postNotificationName:MPPasteBoardControllerDidClearClipboard object:self]; } self.isEmpty = YES; diff --git a/MacPass/MPPluginConstants.h b/MacPass/MPPluginConstants.h new file mode 100644 index 00000000..a53b8a4f --- /dev/null +++ b/MacPass/MPPluginConstants.h @@ -0,0 +1,13 @@ +// +// MPPluginConstants.h +// MacPass +// +// Created by Michael Starke on 29.11.17. +// Copyright © 2017 HicknHack Software GmbH. All rights reserved. +// + +#ifndef MPPluginConstants_h +#define MPPluginConstants_h + + +#endif /* MPPluginConstants_h */ diff --git a/MacPass/MPPluginConstants.m b/MacPass/MPPluginConstants.m new file mode 100644 index 00000000..782d838f --- /dev/null +++ b/MacPass/MPPluginConstants.m @@ -0,0 +1,9 @@ +// +// MPPluginConstants.m +// MacPass +// +// Created by Michael Starke on 29.11.17. +// Copyright © 2017 HicknHack Software GmbH. All rights reserved. +// + +#import