Initialize appkit only once.
authorayin <ayin>
Mon, 12 Nov 2007 14:41:42 +0000 (14:41 +0000)
committerayin <ayin>
Mon, 12 Nov 2007 14:41:42 +0000 (14:41 +0000)
src/perl/macosx-clipboard

index b4e7ae46086eb384a6abc6409afe2649923748b6..2a500f4d49aba56323167db382d8eca14405a995 100644 (file)
@@ -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) = @_;