From: mental Date: Sun, 21 May 2006 20:36:01 +0000 (+0000) Subject: call GC::request_early_collection() after switching preview images X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=28cbcfb64d7da9f861f9e080713c04760d84ee58;p=inkscape.git call GC::request_early_collection() after switching preview images --- diff --git a/ChangeLog b/ChangeLog index f14540efc..a9639be4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-05-21 MenTaLguY + + * 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 * src/layer-manager.cpp, src/layer-manager.h, diff --git a/src/dialogs/filedialog.cpp b/src/dialogs/filedialog.cpp index bf9eaceb5..fb6e599a8 100644 --- a/src/dialogs/filedialog.cpp +++ b/src/dialogs/filedialog.cpp @@ -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) diff --git a/src/gc-core.h b/src/gc-core.h index cec617d42..faf7eb4de 100644 --- a/src/gc-core.h +++ b/src/gc-core.h @@ -128,6 +128,8 @@ inline void init() { Core::init(); } +void request_early_collection(); + } } diff --git a/src/gc.cpp b/src/gc.cpp index 7333b4641..8d89de26a 100644 --- a/src/gc.cpp +++ b/src/gc.cpp @@ -12,6 +12,8 @@ #include "gc-core.h" #include #include +#include +#include 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)); + } +} + } }