2007-02-16 Andreia Gaita <avidigal@novell.com>
authorAndreia Gaita <avidigal@novell.com>
Fri, 16 Feb 2007 23:11:30 +0000 (23:11 -0000)
committerAndreia Gaita <avidigal@novell.com>
Fri, 16 Feb 2007 23:11:30 +0000 (23:11 -0000)
* PrintPreviewControl/PrintPreviewDialog: Properly dispose of
print preview images.

svn path=/trunk/mcs/; revision=73049

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewDialog.cs

index 3971379d4255ce8886cae4d8e313b762a067130c..3eb63a71e89360c4d43571bbb94f167116ba8e8d 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-16  Andreia Gaita  <avidigal@novell.com>
+
+       * PrintPreviewControl/PrintPreviewDialog: Properly dispose of 
+       print preview images.
+
 2007-02-16  Jackson Harper  <jackson@ximian.com>
 
        * ListView.cs: Make AfterLabelEdit work correctly.
index 6d05efc577e075c239a56f27dbfee40f6abacb16..e8ba07ed71c58a0be5c8d7cc6d3900325fa31bc7 100644 (file)
@@ -185,12 +185,14 @@ namespace System.Windows.Forms {
                #region Public Instance Methods
                internal void GeneratePreview ()
                {
-                       try {
-                               if (document == null)
-                                       return;
+                       if (document == null)
+                               return;
 
+                       try {
                                if (page_infos == null) {
-                                       document.PrintController = new PrintControllerWithStatusDialog (controller);
+                                       if (document.PrintController == null || !(document.PrintController is PrintControllerWithStatusDialog)) {
+                                               document.PrintController = new PrintControllerWithStatusDialog (controller);
+                                       }
                                        document.Print ();
                                        page_infos = controller.GetPreviewPageInfo ();
                                }
@@ -223,8 +225,21 @@ namespace System.Windows.Forms {
 
                public void InvalidatePreview()
                {
-                       page_infos = null;
-                       image_cache = null;
+                       if (page_infos != null) {
+                               for (int i = 0; i < page_infos.Length; i++) {
+                                       if (page_infos[i].Image != null) {
+                                               page_infos[i].Image.Dispose();
+                                       }
+                               }
+                               page_infos = null;
+                       }
+                       if (image_cache != null) {
+                               for (int i = 0; i < image_cache.Length; i++) {
+                                       if (image_cache[i] !=null)
+                                               image_cache[i].Dispose();
+                               }
+                               image_cache = null;
+                       }
                }
 
                [EditorBrowsable(EditorBrowsableState.Never)]
index 6ff7dadb9caa8c4ec2433c9c4e2ee8ba7339269b..455d726e1f844a8532dd47c7fea77548fa63f1be 100644 (file)
@@ -788,6 +788,7 @@ namespace System.Windows.Forms {
                }
 
                protected override void OnClosing(CancelEventArgs e) {
+                       print_preview.InvalidatePreview ();
                        base.OnClosing (e);
                }