From b8c086b3633b2bd015b12fc25839b34748c61c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 16 Apr 2008 21:23:45 +0000 Subject: [PATCH] a leak in DocumentClassBundle. However, I am not really sure we should care about these. It's not much difference, except that application shutdown in slower after 'fixing' them. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24305 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 4 ++-- src/TextClass.cpp | 43 +++++++++++++++++++++++++++++++++++++------ src/TextClass.h | 7 ++++--- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 3ddbb58b26..1957c9777f 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -214,8 +214,8 @@ struct BufferView::Private { Private(BufferView & bv): wh_(0), cursor_(bv), anchor_pit_(0), anchor_ypos_(0), - inlineCompletionUniqueChars(0) - last_inset_(0), gui_(0), + inlineCompletionUniqueChars_(0), + last_inset_(0), gui_(0) {} /// diff --git a/src/TextClass.cpp b/src/TextClass.cpp index b86086c579..ef6b8e8f66 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -117,6 +117,12 @@ docstring const TextClass::emptylayout_ = from_ascii("Plain Layout"); InsetLayout DocumentClass::empty_insetlayout_; +///////////////////////////////////////////////////////////////////////// +// +// TextClass +// +///////////////////////////////////////////////////////////////////////// + TextClass::TextClass() { outputType_ = LATEX; @@ -1035,23 +1041,36 @@ Layout const & TextClass::defaultLayout() const } -bool TextClass::isDefaultLayout(Layout const & lay) const +bool TextClass::isDefaultLayout(Layout const & layout) const { - return lay.name() == defaultLayoutName(); + return layout.name() == defaultLayoutName(); } -bool TextClass::isEmptyLayout(Layout const & lay) const +bool TextClass::isEmptyLayout(Layout const & layout) const { - return lay.name() == emptyLayoutName(); + return layout.name() == emptyLayoutName(); } +///////////////////////////////////////////////////////////////////////// +// +// DocumentClassBundle +// +///////////////////////////////////////////////////////////////////////// + +DocumentClassBundle::~DocumentClassBundle() +{ + for (size_t i = 0; i != documentClasses_.size(); ++i) + delete documentClasses_[i]; + documentClasses_.clear(); +} + DocumentClass & DocumentClassBundle::newClass(LayoutFile const & baseClass) { DocumentClass * dc = new DocumentClass(baseClass); - tc_list_.push_back(dc); - return *tc_list_.back(); + documentClasses_.push_back(dc); + return *documentClasses_.back(); } @@ -1062,6 +1081,12 @@ DocumentClassBundle & DocumentClassBundle::get() } +///////////////////////////////////////////////////////////////////////// +// +// DocumentClass +// +///////////////////////////////////////////////////////////////////////// + DocumentClass::DocumentClass(LayoutFile const & tc) : TextClass(tc) {} @@ -1090,6 +1115,12 @@ bool DocumentClass::hasTocLevels() const } +///////////////////////////////////////////////////////////////////////// +// +// PageSides +// +///////////////////////////////////////////////////////////////////////// + ostream & operator<<(ostream & os, PageSides p) { switch (p) { diff --git a/src/TextClass.h b/src/TextClass.h index 71a2241a40..13d2234873 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -24,7 +24,6 @@ #include -#include #include #include #include @@ -364,7 +363,7 @@ protected: /// Constructs a DocumentClass based upon a LayoutFile. DocumentClass(LayoutFile const & tc); /// Needed in tex2lyx - DocumentClass() {}; + DocumentClass() {} private: /// The only class that can create a DocumentClass is /// DocumentClassBundle, which calls the protected constructor. @@ -393,8 +392,10 @@ public: private: /// control instantiation DocumentClassBundle() {} + /// clean up + ~DocumentClassBundle(); /// - std::list tc_list_; + std::vector documentClasses_; };