From c00ffe02ce23a5a271c930e955f6f1613559c3db Mon Sep 17 00:00:00 2001 From: ayin Date: Mon, 12 Nov 2007 14:41:42 +0000 Subject: [PATCH] Initialize appkit only once. --- src/perl/macosx-clipboard | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/perl/macosx-clipboard b/src/perl/macosx-clipboard index b4e7ae46..2a500f4d 100644 --- a/src/perl/macosx-clipboard +++ b/src/perl/macosx-clipboard @@ -37,6 +37,20 @@ use utf8; our($appkit, $pasteboard); +$appkit = NSBundle->alloc->init->initWithPath_('/System/Library/Frameworks/AppKit.framework'); +$appkit->load if $appkit; + +if ($appkit->isLoaded) { + no strict 'refs'; + for my $class (qw(NSPasteboard)) { + @{$class . '::ISA'} = 'PerlObjCBridge'; + } +} else { + undef $appkit; +} + +$pasteboard = NSPasteboard->generalPasteboard; + sub copy { my ($self) = @_; @@ -59,25 +73,6 @@ sub paste { () } -sub on_start { - my ($self) = @_; - - $appkit = NSBundle->alloc->init->initWithPath_('/System/Library/Frameworks/AppKit.framework'); - $appkit->load if $appkit; - - if ($appkit->isLoaded) { - no strict 'refs'; - for my $class (qw(NSPasteboard)) { - @{$class . '::ISA'} = 'PerlObjCBridge'; - } - } else { - undef $appkit; - } - - $pasteboard = NSPasteboard->generalPasteboard; - () -} - sub on_user_command { my ($self, $cmd) = @_; -- 2.34.1