Code

call GC::request_early_collection() after switching preview images
authormental <mental@users.sourceforge.net>
Sun, 21 May 2006 20:36:01 +0000 (20:36 +0000)
committermental <mental@users.sourceforge.net>
Sun, 21 May 2006 20:36:01 +0000 (20:36 +0000)
ChangeLog
src/dialogs/filedialog.cpp
src/gc-core.h
src/gc.cpp

index f14540efc43b09eb2de33d7b76e117ef5a529f56..a9639be4e9671a08312564a03d8aa72ff0c0efdf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-05-21  MenTaLguY  <mental@rydia.net>
+
+       * src/gc-core.h, src/gc.cpp:
+       
+         add GC::request_early_collection() to force a collection from the idle
+         loop at opportune times
+
+       * src/dialogs/filedialog.cpp:
+
+         call GC::request_early_collection() after switching preview images
+
 2006-05-21  Jon A. Cruz  <jon@joncruz.org>
 
        * src/layer-manager.cpp, src/layer-manager.h,
index bf9eaceb55b3a7613ae60b166317dce42e37c2c9..fb6e599a8e25745e4a38a23a0ba8f2dbcab2205d 100644 (file)
@@ -45,6 +45,7 @@
 #include "inkscape.h"
 #include "svg-view-widget.h"
 #include "filedialog.h"
+#include "gc-core.h"
 
 #undef INK_DUMP_FILENAME_CONV
 
@@ -175,6 +176,8 @@ bool SVGPreview::setFromMem(char const *xmlBuffer)
 
     sp_document_unref(doc);
 
+    Inkscape::GC::request_early_collection();
+
     return true;
 }
 
@@ -675,10 +678,8 @@ private:
 void FileOpenDialogImpl::updatePreviewCallback()
 {
     Glib::ustring fileName = get_preview_filename();
-
     if (fileName.length() < 1)
         return;
-
     svgPreview.set(fileName, dialogType);
 }
 
@@ -897,6 +898,7 @@ FileOpenDialogImpl::show()
     set_modal (TRUE);                      //Window
     sp_transientize((GtkWidget *)gobj());  //Make transient
     gint b = run();                        //Dialog
+    svgPreview.showNoPreview();
     hide();
 
     if (b == Gtk::RESPONSE_OK)
@@ -1344,6 +1346,7 @@ FileSaveDialogImpl::show()
     set_modal (TRUE);                      //Window
     sp_transientize((GtkWidget *)gobj());  //Make transient
     gint b = run();                        //Dialog
+    svgPreview.showNoPreview();
     hide();
 
     if (b == Gtk::RESPONSE_OK)
index cec617d426bb2857e5f1b5fd6db8d583f9f90532..faf7eb4de9b1b4a63426c33dc5126186b39ad43c 100644 (file)
@@ -128,6 +128,8 @@ inline void init() {
     Core::init();
 }
 
+void request_early_collection();
+
 }
 }
 
index 7333b4641bd0b3e2bedda6d0a8664c8d9a1dfeaf..8d89de26a69784f9c2d62ec5576e7db50c760210 100644 (file)
@@ -12,6 +12,8 @@
 #include "gc-core.h"
 #include <stdexcept>
 #include <glib/gmessages.h>
+#include <sigc++/functors/ptr_fun.h>
+#include <glibmm/main.h>
 
 namespace Inkscape {
 namespace GC {
@@ -264,6 +266,26 @@ void Core::init() {
     _ops.do_init();
 }
 
+
+namespace {
+
+bool collection_requested=false;
+bool collection_task() {
+    Core::gcollect();
+    Core::gcollect();
+    collection_requested=false;
+    return false;
+}
+
+}
+
+void request_early_collection() {
+    if (!collection_requested) {
+        collection_requested=true;
+        Glib::signal_idle().connect(sigc::ptr_fun(&collection_task));
+    }
+}
+
 }
 }