diff libgui/graphics/Figure.cc @ 20323:c36f2b083613

make copying figures to clipboard work (bug #44866) * Figure.cc (Figure::copy_figure_callback): Just print the figure to a file here, then call octave_link::copy_image_to_clipboard. (delete_file): Delete unused static function. * main-window.h, main-window.cc (main_window::copy_image_to_clipboard): New function. (main_window::construct_octave_qt_link): Connect octave_qt_link::copy_image_to_clipboard_signal signal to main_window::copy_image_to_clipboard slot. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::do_copy_image_to_clipboard): New function. (octave_qt_link::copy_image_to_clipboard_signal): New signal. * octave-link.h (octave_link::do_copy_image_to_clipboard): New pure virtual function. (octave_link::copy_image_to_clipboard): New static funtion.
author John W. Eaton <jwe@octave.org>
date Wed, 22 Apr 2015 00:36:24 -0500
parents c58cf3a65519
children 5f0cb9bb6a50
line wrap: on
line diff
--- a/libgui/graphics/Figure.cc
+++ b/libgui/graphics/Figure.cc
@@ -816,19 +816,11 @@
   Ffeval (ovl ("print", file));
 }
 
-static void
-delete_file (const std::string& file)
-{
-  octave_unlink (file);
-}
-  
 void
 Figure::copy_figure_callback (const std::string& format)
 {
   std::string msg;
 
-  unwind_protect frame;
-
   std::string file = octave_tempnam ("", "oct-", msg) + "." + format;
 
   if (file.empty ())
@@ -837,23 +829,11 @@
       return;
     }
 
-  frame.add_fcn (delete_file, file);
-
   std::string device = "-d" + format;
 
   Ffeval (ovl ("print", file, device));
 
-  QClipboard *clipboard = QApplication::clipboard ();
-
-  QImage img (file.c_str (), format.c_str ());
-
-  if (img.isNull ())
-    {
-      // Report error?
-      return;
-    }
-
-  clipboard->setImage (img);
+  octave_link::copy_image_to_clipboard (file);
 }
   
 void