fix some memory leaks

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24299 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2008-04-16 19:43:06 +00:00
parent bdc6d56cc7
commit c72634f95e
4 changed files with 20 additions and 4 deletions

View File

@ -47,6 +47,14 @@ LayoutFile::LayoutFile(string const & fn, string const & cln,
texClassAvail_ = texClassAvail;
}
LayoutFileList::~LayoutFileList()
{
ClassMap::const_iterator it = classmap_.begin();
ClassMap::const_iterator en = classmap_.end();
for (; it != en; ++it) {
delete it->second;
}
}
LayoutFileList & LayoutFileList::get()
{

View File

@ -72,6 +72,7 @@ class LayoutFileList {
public:
///
LayoutFileList() {}
~LayoutFileList();
/// \return The sole instance of this class.
static LayoutFileList & get();
///

View File

@ -58,6 +58,8 @@
#include <QMenuBar>
#include <QString>
#include <boost/shared_ptr.hpp>
#include <algorithm>
#include <ostream>
#include <vector>
@ -1187,7 +1189,7 @@ struct Menus::Impl {
///
MenuDefinition menubar_;
typedef QMap<GuiView *, QHash<QString, Menu *> > NameMap;
typedef QMap<GuiView *, QHash<QString, boost::shared_ptr<Menu> > > NameMap;
/// name to menu for \c menu() method.
NameMap name_map_;
@ -1400,6 +1402,10 @@ MenuDefinition & Menus::Impl::getMenu(QString const & name)
Menus::Menus() : d(new Impl) {}
Menus::~Menus()
{
delete d;
}
void Menus::read(Lexer & lex)
{
@ -1513,7 +1519,7 @@ void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial)
menu->setTitle(label(*m));
qmb->addMenu(menu);
d->name_map_[view][name] = menu;
d->name_map_[view][name] = boost::shared_ptr<Menu>(menu);
}
}
@ -1548,14 +1554,14 @@ void Menus::updateMenu(Menu * qmenu)
Menu * Menus::menu(QString const & name, GuiView & view)
{
LYXERR(Debug::GUI, "Context menu requested: " << fromqstr(name));
Menu * menu = d->name_map_[&view].value(name, 0);
Menu * menu = d->name_map_[&view].value(name, boost::shared_ptr<Menu>()).get();
if (!menu && !name.startsWith("context-")) {
LYXERR0("requested context menu not found: " << fromqstr(name));
return 0;
}
menu = new Menu(&view, name, true);
d->name_map_[&view][name] = menu;
d->name_map_[&view][name] = boost::shared_ptr<Menu>(menu);
return menu;
}

View File

@ -59,6 +59,7 @@ class Menus
{
public:
Menus();
~Menus();
///
bool searchMenu(FuncRequest const & func,