fixed issue with wrong clear timeout when pasting was done inside the clear timeout

This commit is contained in:
Michael Starke
2017-11-29 14:37:13 +01:00
parent eaea14ad9d
commit 5db3950424
3 changed files with 26 additions and 1 deletions

View File

@@ -96,6 +96,9 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
[self copyObjectsWithoutTimeout:objects]; [self copyObjectsWithoutTimeout:objects];
if(self.clearTimeout != 0) { if(self.clearTimeout != 0) {
[NSNotificationCenter.defaultCenter postNotificationName:MPPasteBoardControllerDidCopyObjects object:self]; [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]; [self performSelector:@selector(_clearPasteboardContents) withObject:nil afterDelay:self.clearTimeout];
} }
} }
@@ -140,7 +143,7 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
- (void)_clearPasteboardContents { - (void)_clearPasteboardContents {
/* Only clear stuff we might have put there */ /* Only clear stuff we might have put there */
if(!self.isEmpty) { if(!self.isEmpty) {
[[NSPasteboard generalPasteboard] clearContents]; [NSPasteboard.generalPasteboard clearContents];
[NSNotificationCenter.defaultCenter postNotificationName:MPPasteBoardControllerDidClearClipboard object:self]; [NSNotificationCenter.defaultCenter postNotificationName:MPPasteBoardControllerDidClearClipboard object:self];
} }
self.isEmpty = YES; self.isEmpty = YES;

View File

@@ -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 */

View File

@@ -0,0 +1,9 @@
//
// MPPluginConstants.m
// MacPass
//
// Created by Michael Starke on 29.11.17.
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>