From 350476a133a3965b1d7047d2f0f05bf809b177ba Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 21 Aug 2013 13:01:40 +0200 Subject: better memory leak fix (fixes bug 986271: memory leaks associated with images) Patch by David Mathog, including revert of former fix in rev 11268 (bzr r12482) --- src/extension/internal/emf-win32-print.cpp | 12 ------------ src/extension/internal/emf-win32-print.h | 7 ------- src/sp-image.cpp | 1 + 3 files changed, 1 insertion(+), 19 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 621954f68..92f564078 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -910,18 +910,6 @@ void PrintEmfWin32::init (void) return; } -unsigned int PrintEmfWin32::image(Inkscape::Extension::Print * /* module */, /** not used */ - unsigned char *px, /** array of pixel values, Gdk::Pixbuf bitmap format */ - unsigned int /*w*/, /** width of bitmap */ - unsigned int /*h*/, /** height of bitmap */ - unsigned int /*rs*/, /** row stride (normally w*4) */ - Geom::Affine const & /*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */ - SPStyle const * /*style*/) /** provides indirect link to image object */ -{ - free(px); - return 0; -} - } /* namespace Internal */ } /* namespace Extension */ } /* namespace Inkscape */ diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index e7bd08477..bbeeeb051 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -50,13 +50,6 @@ class PrintEmfWin32 : public Inkscape::Extension::Implementation::Implementation unsigned int print_pathv (Geom::PathVector const &pathv, const Geom::Affine &transform); bool print_simple_shape (Geom::PathVector const &pathv, const Geom::Affine &transform); - unsigned int image(Inkscape::Extension::Print * /* module */, /** not used */ - unsigned char *px, /** array of pixel values, Gdk::Pixbuf bitmap format */ - unsigned int w, /** width of bitmap */ - unsigned int h, /** height of bitmap */ - unsigned int rs, /** row stride (normally w*4) */ - Geom::Affine const &tf_ignore, /** WRONG affine transform, use the one from m_tr_stack */ - SPStyle const *style); /** provides indirect link to image object */ public: PrintEmfWin32 (void); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index d60fbc181..10d294d5c 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1056,6 +1056,7 @@ static void sp_image_print( SPItem *item, SPPrintContext *ctx ) t = ti * t; sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, t, item->style); } + free(px); // else big memory leak on each image print! } } -- cgit v1.2.3 From 205e7c81bd2f536b394a0786111bf60c0aac1df6 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 25 Aug 2013 19:40:15 -0700 Subject: Updating outdated test. Fixes bug #1202271. Fixed bugs: - https://launchpad.net/bugs/1202271 (bzr r12487) --- src/preferences-test.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/preferences-test.h b/src/preferences-test.h index 8e8ddb65b..92cb14247 100644 --- a/src/preferences-test.h +++ b/src/preferences-test.h @@ -18,7 +18,7 @@ public: TestObserver(Glib::ustring const &path) : Inkscape::Preferences::Observer(path), value(0) {} - + virtual void notify(Inkscape::Preferences::Entry const &val) { value = val.getInt(); @@ -35,29 +35,29 @@ public: prefs = NULL; Inkscape::Preferences::unload(); } - + void testStartingState() { - TS_ASSERT(prefs != NULL); - TS_ASSERT_EQUALS(prefs->isWritable(), false); + TS_ASSERT_DIFFERS(prefs, static_cast(0)); + TS_ASSERT_EQUALS(prefs->isWritable(), true); } - + void testOverwrite() { prefs->setInt("/test/intvalue", 123); prefs->setInt("/test/intvalue", 321); TS_ASSERT_EQUALS(prefs->getInt("/test/intvalue"), 321); } - + void testDefaultReturn() { TS_ASSERT_EQUALS(prefs->getInt("/this/path/does/not/exist", 123), 123); } - + void testLimitedReturn() { prefs->setInt("/test/intvalue", 1000); - + // simple case TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 0, 500), 123); // the below may seem quirky but this behaviour is intended @@ -66,7 +66,7 @@ public: TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 0, 1000), 1000); TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 1000, 5000), 1000); } - + void testKeyObserverNotification() { Glib::ustring const path = "/some/random/path"; @@ -74,18 +74,18 @@ public: obs.value = 1; prefs->setInt(path, 5); TS_ASSERT_EQUALS(obs.value, 1); // no notifications sent before adding - + prefs->addObserver(obs); prefs->setInt(path, 10); TS_ASSERT_EQUALS(obs.value, 10); prefs->setInt("/some/other/random/path", 10); TS_ASSERT_EQUALS(obs.value, 10); // value should not change - + prefs->removeObserver(obs); prefs->setInt(path, 15); TS_ASSERT_EQUALS(obs.value, 10); // no notifications sent after removal } - + void testEntryObserverNotification() { Glib::ustring const path = "/some/random/path"; @@ -93,11 +93,11 @@ public: obs.value = 1; prefs->setInt(path, 5); TS_ASSERT_EQUALS(obs.value, 1); // no notifications sent before adding - + prefs->addObserver(obs); prefs->setInt(path, 10); TS_ASSERT_EQUALS(obs.value, 10); - + // test that filtering works properly prefs->setInt("/some/random/value", 1234); TS_ASSERT_EQUALS(obs.value, 10); @@ -105,12 +105,12 @@ public: TS_ASSERT_EQUALS(obs.value, 10); prefs->setInt("/some/random/path2", 1234); TS_ASSERT_EQUALS(obs.value, 10); - + prefs->removeObserver(obs); prefs->setInt(path, 15); TS_ASSERT_EQUALS(obs.value, 10); // no notifications sent after removal } - + void testPreferencesEntryMethods() { prefs->setInt("/test/prefentry", 100); -- cgit v1.2.3