[EMAIL PROTECTED] (Lars Gullik Bj�nnes) writes:
| Since we are almost tempted to use exceptions...
>
| This is aimed at fixing memory leaks in the case of exceptions...
| (probably not all good, neither does it fix all problems...)
Updated patch.
? Config
? exception-safety-2.diff
? exception-safety.diff
? src/lyxvc.lo
Index: boost/boost/iterator_adaptors.hpp
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/boost/boost/iterator_adaptors.hpp,v
retrieving revision 1.5
diff -u -p -r1.5 iterator_adaptors.hpp
--- boost/boost/iterator_adaptors.hpp 3 Mar 2003 15:53:40 -0000 1.5
+++ boost/boost/iterator_adaptors.hpp 3 Nov 2003 10:13:39 -0000
@@ -235,7 +235,7 @@ struct default_iterator_policies
{
// Some of the member functions were defined static, but Borland
// got confused and thought they were non-const. Also, Sun C++
- // does not like static function templates.
+ // does not like static function templates.
//
// The reason some members were defined static is because there is
// not state (data members) needed by those members of the
@@ -1432,6 +1432,3 @@ make_filter_iterator(Iterator first, Ite
#endif
-
-
-
Index: po/POTFILES.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/po/POTFILES.in,v
retrieving revision 1.364
diff -u -p -r1.364 POTFILES.in
--- po/POTFILES.in 29 Oct 2003 13:24:53 -0000 1.364
+++ po/POTFILES.in 3 Nov 2003 10:13:40 -0000
@@ -194,7 +194,6 @@ src/mathed/ref_inset.C
src/paragraph.C
src/paragraph_funcs.C
src/rowpainter.C
-src/support/path_defines.C
src/text.C
src/text2.C
src/text3.C
Index: src/MenuBackend.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.C,v
retrieving revision 1.92
diff -u -p -r1.92 MenuBackend.C
--- src/MenuBackend.C 25 Oct 2003 09:20:51 -0000 1.92
+++ src/MenuBackend.C 3 Nov 2003 10:13:40 -0000
@@ -51,6 +51,7 @@ using lyx::support::contains;
using lyx::support::MakeDisplayPath;
using lyx::support::token;
+using std::auto_ptr;
using std::endl;
using std::find_if;
using std::max;
@@ -598,7 +599,7 @@ void expandToc(Menu & tomenu, LyXView co
continue;
// All the rest is for floats
- Menu * menu = new Menu;
+ auto_ptr<Menu> menu(new Menu);
lyx::toc::Toc::const_iterator ccit = cit->second.begin();
lyx::toc::Toc::const_iterator eend = cit->second.end();
for (; ccit != eend; ++ccit) {
@@ -610,7 +611,7 @@ void expandToc(Menu & tomenu, LyXView co
string const & floatName = cit->first;
// Is the _(...) really needed here? (Lgb)
MenuItem item(MenuItem::Submenu, _(floatName));
- item.submenu(menu);
+ item.submenu(menu.release());
tomenu.add(item);
}
Index: src/Thesaurus.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Thesaurus.C,v
retrieving revision 1.10
diff -u -p -r1.10 Thesaurus.C
--- src/Thesaurus.C 6 Oct 2003 15:42:04 -0000 1.10
+++ src/Thesaurus.C 3 Nov 2003 10:13:40 -0000
@@ -23,9 +23,8 @@ using std::sort;
Thesaurus::Thesaurus()
-{
- aik_ = new Aiksaurus;
-}
+ : aik_(new Aiksaurus)
+{}
Thesaurus::~Thesaurus()
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.539
diff -u -p -r1.539 buffer.C
--- src/buffer.C 2 Nov 2003 17:56:25 -0000 1.539
+++ src/buffer.C 3 Nov 2003 10:13:41 -0000
@@ -1475,13 +1475,13 @@ bool Buffer::hasParWithID(int id) const
PosIterator Buffer::pos_iterator_begin()
{
- return PosIterator(¶graphs(), paragraphs().begin(), 0);
+ return PosIterator(¶graphs(), paragraphs().begin(), 0);
}
PosIterator Buffer::pos_iterator_end()
{
- return PosIterator(¶graphs(), paragraphs().end(), 0);
+ return PosIterator(¶graphs(), paragraphs().end(), 0);
}
Index: src/bufferlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v
retrieving revision 1.137
diff -u -p -r1.137 bufferlist.C
--- src/bufferlist.C 17 Oct 2003 09:32:41 -0000 1.137
+++ src/bufferlist.C 3 Nov 2003 10:13:41 -0000
@@ -38,6 +38,7 @@ using lyx::support::OnlyFilename;
using lyx::support::removeAutosaveFile;
using lyx::support::prefixIs;
+using std::auto_ptr;
using std::endl;
using std::find;
using std::find_if;
@@ -127,12 +128,12 @@ void BufferList::release(Buffer * buf)
Buffer * BufferList::newBuffer(string const & s, bool ronly)
{
- Buffer * tmpbuf = new Buffer(s, ronly);
+ auto_ptr<Buffer> tmpbuf(new Buffer(s, ronly));
tmpbuf->params().useClassDefaults();
lyxerr[Debug::INFO] << "Assigning to buffer "
<< bstore.size() << endl;
- bstore.push_back(tmpbuf);
- return tmpbuf;
+ bstore.push_back(tmpbuf.get());
+ return tmpbuf.release();
}
Index: src/factory.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v
retrieving revision 1.65
diff -u -p -r1.65 factory.C
--- src/factory.C 27 Oct 2003 12:41:19 -0000 1.65
+++ src/factory.C 3 Nov 2003 10:13:41 -0000
@@ -20,6 +20,7 @@
#include "funcrequest.h"
#include "LColor.h"
#include "lyxlex.h"
+#include "paragraph.h"
#include "insets/insetbibitem.h"
#include "insets/insetbibtex.h"
@@ -62,6 +63,7 @@
using lyx::support::compare_ascii_no_case;
+using std::auto_ptr;
using std::endl;
using std::string;
@@ -130,8 +132,9 @@ InsetOld * createInset(FuncRequest const
case LFUN_INSET_WIDE_FLOAT:
// check if the float type exists
if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
- InsetFloat * p = new InsetFloat(params, cmd.argument);
+ auto_ptr<InsetFloat> p(new InsetFloat(params, cmd.argument));
p->wide(true, params);
+ return p.release();
}
lyxerr << "Non-existent float type: " << cmd.argument << endl;
return 0;
@@ -177,12 +180,12 @@ InsetOld * createInset(FuncRequest const
if (bv->theLockingInset()) {
lyxerr << "Locking inset code: "
<< static_cast<int>(bv->theLockingInset()->lyxCode());
- InsetCaption * inset = new InsetCaption(params);
+ auto_ptr<InsetCaption> inset(new InsetCaption(params));
inset->setOwner(bv->theLockingInset());
inset->setAutoBreakRows(true);
inset->setDrawFrame(InsetText::LOCKED);
inset->setFrameColor(LColor::captionframe);
- return inset;
+ return inset.release();
}
return 0;
@@ -233,18 +236,18 @@ InsetOld * createInset(FuncRequest const
InsetExternalParams iep;
InsetExternalMailer::string2params(cmd.argument,
buffer, iep);
- InsetExternal * inset = new InsetExternal;
+ auto_ptr<InsetExternal> inset(new InsetExternal);
inset->setParams(iep, buffer);
- return inset;
+ return inset.release();
} else if (name == "graphics") {
Buffer const & buffer = *cmd.view()->buffer();
InsetGraphicsParams igp;
InsetGraphicsMailer::string2params(cmd.argument,
buffer, igp);
- InsetGraphics * inset = new InsetGraphics;
+ auto_ptr<InsetGraphics> inset(new InsetGraphics);
inset->setParams(igp);
- return inset;
+ return inset.release();
} else if (name == "include") {
InsetCommandParams iip;
@@ -320,7 +323,7 @@ InsetOld * readInset(LyXLex & lex, Buffe
<< endl;
}
- InsetOld * inset = 0;
+ auto_ptr<InsetOld> inset;
lex.next();
string const tmptok = lex.getString();
@@ -335,21 +338,21 @@ InsetOld * readInset(LyXLex & lex, Buffe
// This strange command allows LyX to recognize "natbib" style
// citations: citet, citep, Citet etc.
if (compare_ascii_no_case(cmdName.substr(0,4), "cite") == 0) {
- inset = new InsetCitation(inscmd);
+ inset.reset(new InsetCitation(inscmd));
} else if (cmdName == "bibitem") {
lex.printError("Wrong place for bibitem");
- inset = new InsetBibitem(inscmd);
+ inset.reset(new InsetBibitem(inscmd));
} else if (cmdName == "bibtex") {
- inset = new InsetBibtex(inscmd);
+ inset.reset(new InsetBibtex(inscmd));
} else if (cmdName == "index") {
- inset = new InsetIndex(inscmd);
+ inset.reset(new InsetIndex(inscmd));
} else if (cmdName == "include") {
- inset = new InsetInclude(inscmd);
+ inset.reset(new InsetInclude(inscmd));
} else if (cmdName == "label") {
- inset = new InsetLabel(inscmd);
+ inset.reset(new InsetLabel(inscmd));
} else if (cmdName == "url"
|| cmdName == "htmlurl") {
- inset = new InsetUrl(inscmd);
+ inset.reset(new InsetUrl(inscmd));
} else if (cmdName == "ref"
|| cmdName == "eqref"
|| cmdName == "pageref"
@@ -358,18 +361,18 @@ InsetOld * readInset(LyXLex & lex, Buffe
|| cmdName == "prettyref") {
if (!inscmd.getOptions().empty()
|| !inscmd.getContents().empty()) {
- inset = new InsetRef(inscmd, buf);
+ inset.reset(new InsetRef(inscmd, buf));
}
} else if (cmdName == "tableofcontents") {
- inset = new InsetTOC(inscmd);
+ inset.reset(new InsetTOC(inscmd));
} else if (cmdName == "listofalgorithms") {
- inset = new InsetFloatList("algorithm");
+ inset.reset(new InsetFloatList("algorithm"));
} else if (cmdName == "listoffigures") {
- inset = new InsetFloatList("figure");
+ inset.reset(new InsetFloatList("figure"));
} else if (cmdName == "listoftables") {
- inset = new InsetFloatList("table");
+ inset.reset(new InsetFloatList("table"));
} else if (cmdName == "printindex") {
- inset = new InsetPrintIndex(inscmd);
+ inset.reset(new InsetPrintIndex(inscmd));
} else {
lyxerr << "unknown CommandInset '" << cmdName
<< "'" << std::endl;
@@ -379,64 +382,64 @@ InsetOld * readInset(LyXLex & lex, Buffe
}
} else {
if (tmptok == "Quotes") {
- inset = new InsetQuotes;
+ inset.reset(new InsetQuotes);
} else if (tmptok == "External") {
- inset = new InsetExternal;
+ inset.reset(new InsetExternal);
} else if (tmptok == "FormulaMacro") {
- inset = new InsetFormulaMacro;
+ inset.reset(new InsetFormulaMacro);
} else if (tmptok == "Formula") {
- inset = new InsetFormula;
+ inset.reset(new InsetFormula);
} else if (tmptok == "Graphics") {
- inset = new InsetGraphics;
+ inset.reset(new InsetGraphics);
} else if (tmptok == "Note" || tmptok == "Comment"
|| tmptok == "Greyedout") {
- inset = new InsetNote(buf.params(), tmptok);
+ inset.reset(new InsetNote(buf.params(), tmptok));
} else if (tmptok == "Boxed" || tmptok == "ovalbox"
|| tmptok == "Shadowbox" || tmptok == "Doublebox"
|| tmptok == "Ovalbox" || tmptok == "Frameless") {
- inset = new InsetBox(buf.params(), tmptok);
+ inset.reset(new InsetBox(buf.params(), tmptok));
} else if (tmptok == "Branch") {
- inset = new InsetBranch(buf.params(), string());
+ inset.reset(new InsetBranch(buf.params(), string()));
} else if (tmptok == "Include") {
InsetCommandParams p("Include");
- inset = new InsetInclude(p);
+ inset.reset(new InsetInclude(p));
} else if (tmptok == "Environment") {
lex.next();
- inset = new InsetEnvironment(buf.params(), lex.getString());
+ inset.reset(new InsetEnvironment(buf.params(), lex.getString()));
} else if (tmptok == "ERT") {
- inset = new InsetERT(buf.params());
+ inset.reset(new InsetERT(buf.params()));
} else if (tmptok == "InsetSpace") {
- inset = new InsetSpace;
+ inset.reset(new InsetSpace);
} else if (tmptok == "Tabular") {
- inset = new InsetTabular(buf);
+ inset.reset(new InsetTabular(buf));
} else if (tmptok == "Text") {
- inset = new InsetText(buf.params());
+ inset.reset(new InsetText(buf.params()));
} else if (tmptok == "Foot") {
- inset = new InsetFoot(buf.params());
+ inset.reset(new InsetFoot(buf.params()));
} else if (tmptok == "Marginal") {
- inset = new InsetMarginal(buf.params());
+ inset.reset(new InsetMarginal(buf.params()));
} else if (tmptok == "OptArg") {
- inset = new InsetOptArg(buf.params());
+ inset.reset(new InsetOptArg(buf.params()));
} else if (tmptok == "Minipage") {
- inset = new InsetMinipage(buf.params());
+ inset.reset(new InsetMinipage(buf.params()));
} else if (tmptok == "Float") {
lex.next();
string tmptok = lex.getString();
- inset = new InsetFloat(buf.params(), tmptok);
+ inset.reset(new InsetFloat(buf.params(), tmptok));
} else if (tmptok == "Wrap") {
lex.next();
string tmptok = lex.getString();
- inset = new InsetWrap(buf.params(), tmptok);
+ inset.reset(new InsetWrap(buf.params(), tmptok));
#if 0
} else if (tmptok == "List") {
- inset = new InsetList;
+ inset.reset(new InsetList);
} else if (tmptok == "Theorem") {
- inset = new InsetList;
+ inset.reset(new InsetList);
#endif
} else if (tmptok == "Caption") {
- inset = new InsetCaption(buf.params());
+ inset.reset(new InsetCaption(buf.params()));
} else if (tmptok == "FloatList") {
- inset = new InsetFloatList;
+ inset.reset(new InsetFloatList);
} else {
lyxerr << "unknown Inset type '" << tmptok
<< "'" << std::endl;
@@ -448,5 +451,5 @@ InsetOld * readInset(LyXLex & lex, Buffe
inset->read(buf, lex);
}
- return inset;
+ return inset.release();
}
Index: src/ispell.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ispell.C,v
retrieving revision 1.21
diff -u -p -r1.21 ispell.C
--- src/ispell.C 6 Oct 2003 15:42:15 -0000 1.21
+++ src/ispell.C 3 Nov 2003 10:13:41 -0000
@@ -36,6 +36,7 @@ using std::strlen;
using std::strpbrk;
#endif
+using std::auto_ptr;
using std::endl;
using std::max;
using std::string;
@@ -50,8 +51,8 @@ public:
int * in, int * out, int * err)
: params(p), lang(l), pipein(in), pipeout(out), pipeerr(err) {}
///
- virtual lyx::support::ForkedProcess * clone() const {
- return new LaunchIspell(*this);
+ virtual auto_ptr<lyx::support::ForkedProcess> clone() const {
+ return auto_ptr<lyx::support::ForkedProcess>(new LaunchIspell(*this));
}
///
int start();
Index: src/iterators.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.C,v
retrieving revision 1.25
diff -u -p -r1.25 iterators.C
--- src/iterators.C 3 Nov 2003 09:23:23 -0000 1.25
+++ src/iterators.C 3 Nov 2003 10:13:41 -0000
@@ -369,7 +369,7 @@ bool operator!=(ParConstIterator const &
PosIterator ParIterator::asPosIterator(lyx::pos_type pos) const
{
PosIterator p;
-
+
int const last = size() - 1;
for (int i = 0; i < last; ++i) {
ParPosition & pp = pimpl_->positions[i];
Index: src/lyx_cb.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
retrieving revision 1.229
diff -u -p -r1.229 lyx_cb.C
--- src/lyx_cb.C 14 Oct 2003 21:30:19 -0000 1.229
+++ src/lyx_cb.C 3 Nov 2003 10:13:41 -0000
@@ -68,6 +68,7 @@ using lyx::support::user_lyxdir;
namespace os = lyx::support::os;
+using std::auto_ptr;
using std::back_inserter;
using std::copy;
using std::endl;
@@ -215,8 +216,8 @@ public:
AutoSaveBuffer(BufferView & bv, string const & fname)
: bv_(bv), fname_(fname) {}
///
- virtual ForkedProcess * clone() const {
- return new AutoSaveBuffer(*this);
+ virtual auto_ptr<ForkedProcess> clone() const {
+ return auto_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
}
///
int start();
Index: src/lyxsocket.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxsocket.C,v
retrieving revision 1.2
diff -u -p -r1.2 lyxsocket.C
--- src/lyxsocket.C 17 Oct 2003 14:30:33 -0000 1.2
+++ src/lyxsocket.C 3 Nov 2003 10:13:41 -0000
@@ -27,6 +27,8 @@
#include <iostream>
#include <cerrno>
+
+using std::auto_ptr;
using std::endl;
using std::string;
@@ -75,17 +77,16 @@ string const & LyXServerSocket::address(
// is OK and if the number of clients does not exceed MAX_CLIENTS
void LyXServerSocket::serverCallback()
{
- LyXDataSocket * client = new LyXDataSocket(this);
+ auto_ptr<LyXDataSocket> client(new LyXDataSocket(this));
if (client->connected()) {
if (clients.size() == MAX_CLIENTS) {
client->writeln("BYE:Too many clients connected");
} else {
- clients.insert(client);
- lyx_gui::set_datasocket_callback(client);
+ lyx_gui::set_datasocket_callback(client.get());
+ clients.insert(client.release());
return;
}
}
- delete client;
}
@@ -141,15 +142,15 @@ void LyXServerSocket::close(LyXDataSocke
// Debug
// void LyXServerSocket::dump() const
// {
-// lyxerr << "LyXServerSocket debug dump.\n"
-// << "fd = " << fd_ << ", address = " << address_ << ".\n"
-// << "Clients: " << clients.size() << ".\n";
-// if (!clients.empty()) {
-// std::set<LyXDataSocket *>::const_iterator client = clients.begin();
-// std::set<LyXDataSocket *>::const_iterator end = clients.end();
-// for (; client != end; ++client)
-// lyxerr << "fd = " << (*client)->fd() << "\n";
-// }
+// lyxerr << "LyXServerSocket debug dump.\n"
+// << "fd = " << fd_ << ", address = " << address_ << ".\n"
+// << "Clients: " << clients.size() << ".\n";
+// if (!clients.empty()) {
+// std::set<LyXDataSocket *>::const_iterator client = clients.begin();
+// std::set<LyXDataSocket *>::const_iterator end = clients.end();
+// for (; client != end; ++client)
+// lyxerr << "fd = " << (*client)->fd() << "\n";
+// }
// }
Index: src/lyxtextclass.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclass.C,v
retrieving revision 1.41
diff -u -p -r1.41 lyxtextclass.C
--- src/lyxtextclass.C 6 Oct 2003 15:42:29 -0000 1.41
+++ src/lyxtextclass.C 3 Nov 2003 10:13:41 -0000
@@ -233,8 +233,10 @@ bool LyXTextClass::Read(string const & f
if (le == TC_ENVIRONMENT)
lay.is_environment = true;
if (!(error = do_readStyle(lexrc, lay)))
- layoutlist_.push_back
- (boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
+ layoutlist_.push_back(
+ boost::shared_ptr<LyXLayout>(new LyXLayout(lay))
+ );
+
if (defaultlayout_.empty()) {
// We do not have a default
// layout yet, so we choose
Index: src/lyxvc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxvc.C,v
retrieving revision 1.53
diff -u -p -r1.53 lyxvc.C
--- src/lyxvc.C 6 Oct 2003 15:42:29 -0000 1.53
+++ src/lyxvc.C 3 Nov 2003 10:13:41 -0000
@@ -38,15 +38,13 @@ using std::pair;
LyXVC::LyXVC()
{
- vcs = 0;
owner_ = 0;
}
+// for the sake of boost::scoped_ptr
LyXVC::~LyXVC()
-{
- delete vcs;
-}
+{}
bool LyXVC::file_found_hook(string const & fn)
@@ -54,13 +52,13 @@ bool LyXVC::file_found_hook(string const
string found_file;
// Check if file is under RCS
if (!(found_file = RCS::find_file(fn)).empty()) {
- vcs = new RCS(found_file);
+ vcs.reset(new RCS(found_file));
vcs->owner(owner_);
return true;
}
// Check if file is under CVS
if (!(found_file = CVS::find_file(fn)).empty()) {
- vcs = new CVS(found_file, fn);
+ vcs.reset(new CVS(found_file, fn));
vcs->owner(owner_);
return true;
}
@@ -107,14 +105,14 @@ void LyXVC::registrer()
<< "LyXVC: registering "
<< MakeDisplayPath(filename)
<< " with CVS" << endl;
- vcs = new CVS(cvs_entries, filename);
+ vcs.reset(new CVS(cvs_entries, filename));
} else {
lyxerr[Debug::LYXVC]
<< "LyXVC: registering "
<< MakeDisplayPath(filename)
<< " with RCS" << endl;
- vcs = new RCS(filename);
+ vcs.reset(new RCS(filename));
}
vcs->owner(owner_);
Index: src/lyxvc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxvc.h,v
retrieving revision 1.16
diff -u -p -r1.16 lyxvc.h
--- src/lyxvc.h 6 Oct 2003 15:42:29 -0000 1.16
+++ src/lyxvc.h 3 Nov 2003 10:13:42 -0000
@@ -12,6 +12,8 @@
#ifndef LYX_VC_H
#define LYX_VC_H
+#include <boost/scoped_ptr.hpp>
+
#include <string>
@@ -100,7 +102,7 @@ private:
Buffer * owner_;
///
- VCS * vcs;
+ boost::scoped_ptr<VCS> vcs;
};
#endif
Index: src/paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.340
diff -u -p -r1.340 paragraph.C
--- src/paragraph.C 31 Oct 2003 18:45:34 -0000 1.340
+++ src/paragraph.C 3 Nov 2003 10:13:42 -0000
@@ -1535,7 +1535,7 @@ bool Paragraph::isMultiLingual(BufferPar
string const Paragraph::asString(Buffer const & buffer,
bool label) const
{
- LatexRunParams runparams;
+ LatexRunParams runparams;
return asString(buffer, runparams, label);
}
Index: src/paragraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
retrieving revision 1.117
diff -u -p -r1.117 paragraph.h
--- src/paragraph.h 31 Oct 2003 18:45:35 -0000 1.117
+++ src/paragraph.h 3 Nov 2003 10:13:42 -0000
@@ -92,7 +92,7 @@ public:
std::string const Paragraph::asString(Buffer const & buffer,
lyx::pos_type beg,
lyx::pos_type end,
- bool label) const;
+ bool label) const;
///
std::string const asString(Buffer const &,
LatexRunParams const & runparams,
Index: src/paragraph_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v
retrieving revision 1.83
diff -u -p -r1.83 paragraph_funcs.C
--- src/paragraph_funcs.C 31 Oct 2003 18:45:35 -0000 1.83
+++ src/paragraph_funcs.C 3 Nov 2003 10:13:42 -0000
@@ -59,6 +59,7 @@ using lyx::support::contains;
using lyx::support::split;
using lyx::support::subst;
+using std::auto_ptr;
using std::endl;
using std::string;
using std::vector;
@@ -996,7 +997,7 @@ void linuxdocParagraphs(Buffer const & b
ostream & os,
LatexRunParams const & runparams)
{
-
+
Paragraph::depth_type depth = 0; // paragraph depth
string item_name;
vector<string> environment_stack(5);
@@ -1154,8 +1155,8 @@ void docbookParagraphs(Buffer const & bu
// environment tag closing
for (; depth > par->params().depth(); --depth) {
- if (!environment_inner[depth].empty())
- sgml::closeEnvTags(os, false, environment_inner[depth],
+ if (!environment_inner[depth].empty())
+ sgml::closeEnvTags(os, false, environment_inner[depth],
command_depth + depth);
sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]);
environment_stack[depth].erase();
@@ -1165,7 +1166,7 @@ void docbookParagraphs(Buffer const & bu
if (depth == par->params().depth()
&& environment_stack[depth] != style->latexname()
&& !environment_stack[depth].empty()) {
- sgml::closeEnvTags(os, false, environment_inner[depth],
+ sgml::closeEnvTags(os, false, environment_inner[depth],
command_depth + depth);
sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]);
@@ -1184,7 +1185,7 @@ void docbookParagraphs(Buffer const & bu
if (depth != 0)
//error(ErrorItem(_("Error"), _("Wrong depth for LatexType Command."), par->id(), 0, par->size()));
;
-
+
command_name = style->latexname();
sgmlparam = style->latexparam();
@@ -1254,7 +1255,7 @@ void docbookParagraphs(Buffer const & bu
environment_inner[depth] = "!-- --";
sgml::openTag(os, depth + command_depth, false, environment_stack[depth]);
} else {
- sgml::closeEnvTags(os, false, environment_inner[depth],
+ sgml::closeEnvTags(os, false, environment_inner[depth],
command_depth + depth);
}
@@ -1320,7 +1321,7 @@ void docbookParagraphs(Buffer const & bu
// Close open tags
for (int d = depth; d >= 0; --d) {
if (!environment_stack[depth].empty()) {
- sgml::closeEnvTags(os, false, environment_inner[depth],
+ sgml::closeEnvTags(os, false, environment_inner[depth],
command_depth + depth);
}
}
@@ -1462,33 +1463,34 @@ int readParToken(Buffer & buf, Paragraph
}
}
} else {
- InsetOld * inset = 0;
+ auto_ptr<InsetOld> inset;
if (token == "\\SpecialChar" )
- inset = new InsetSpecialChar;
+ inset.reset(new InsetSpecialChar);
else
- inset = new InsetSpace;
+ inset.reset(new InsetSpace);
inset->read(buf, lex);
- par.insertInset(par.size(), inset, font, change);
+ par.insertInset(par.size(), inset.release(),
+ font, change);
}
} else if (token == "\\i") {
- InsetOld * inset = new InsetLatexAccent;
+ auto_ptr<InsetOld> inset(new InsetLatexAccent);
inset->read(buf, lex);
- par.insertInset(par.size(), inset, font, change);
+ par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\backslash") {
par.insertChar(par.size(), '\\', font, change);
} else if (token == "\\newline") {
- InsetOld * inset = new InsetNewline;
+ auto_ptr<InsetOld> inset(new InsetNewline);
inset->read(buf, lex);
- par.insertInset(par.size(), inset, font, change);
+ par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\LyXTable") {
- InsetOld * inset = new InsetTabular(buf);
+ auto_ptr<InsetOld> inset(new InsetTabular(buf));
inset->read(buf, lex);
- par.insertInset(par.size(), inset, font, change);
+ par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\bibitem") {
InsetCommandParams p("bibitem", "dummy");
- InsetBibitem * inset = new InsetBibitem(p);
+ auto_ptr<InsetBibitem> inset(new InsetBibitem(p));
inset->read(buf, lex);
- par.insertInset(par.size(), inset, font, change);
+ par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\hfill") {
par.insertInset(par.size(), new InsetHFill, font, change);
} else if (token == "\\lyxline") {
Index: src/rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.87
diff -u -p -r1.87 rowpainter.C
--- src/rowpainter.C 28 Oct 2003 11:18:36 -0000 1.87
+++ src/rowpainter.C 3 Nov 2003 10:13:43 -0000
@@ -416,7 +416,7 @@ void RowPainter::paintSelection()
}
return;
}
-
+
if (startrow != rit_ && endrow != rit_) {
if (y_ > starty && y_ < endy) {
int w = width_;
Index: src/trans_mgr.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/trans_mgr.C,v
retrieving revision 1.45
diff -u -p -r1.45 trans_mgr.C
--- src/trans_mgr.C 6 Oct 2003 15:42:42 -0000 1.45
+++ src/trans_mgr.C 3 Nov 2003 10:13:43 -0000
@@ -191,11 +191,9 @@ TransManager::TransManager()
{}
+// For the sace of boost::scoped_ptr.
TransManager::~TransManager()
-{
- delete t1_;
- delete t2_;
-}
+{}
int TransManager::SetPrimary(string const & language)
@@ -225,7 +223,7 @@ bool TransManager::setCharset(string con
void TransManager::EnablePrimary()
{
if (t1_->IsDefined())
- active_ = t1_;
+ active_ = t1_.get();
lyxerr[Debug::KBMAP] << "Enabling primary keymap" << endl;
}
@@ -234,7 +232,7 @@ void TransManager::EnablePrimary()
void TransManager::EnableSecondary()
{
if (t2_->IsDefined())
- active_ = t2_;
+ active_ = t2_.get();
lyxerr[Debug::KBMAP] << "Enabling secondary keymap" << endl;
}
Index: src/trans_mgr.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/trans_mgr.h,v
retrieving revision 1.20
diff -u -p -r1.20 trans_mgr.h
--- src/trans_mgr.h 6 Oct 2003 15:42:43 -0000 1.20
+++ src/trans_mgr.h 3 Nov 2003 10:13:43 -0000
@@ -17,6 +17,8 @@
#include "chset.h"
#include "trans_decl.h"
+#include <boost/scoped_ptr.hpp>
+
class LyXText;
class Trans;
@@ -137,9 +139,9 @@ private:
///
Trans * active_;
///
- Trans * t1_;
+ boost::scoped_ptr<Trans> t1_;
///
- Trans * t2_;
+ boost::scoped_ptr<Trans> t2_;
///
static Trans default_;
///
@@ -152,7 +154,7 @@ public:
///
TransManager();
///
- virtual ~TransManager();
+ ~TransManager();
///
int SetPrimary(std::string const &);
///
Index: src/undo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v
retrieving revision 1.25
diff -u -p -r1.25 undo.C
--- src/undo.C 29 Oct 2003 12:18:08 -0000 1.25
+++ src/undo.C 3 Nov 2003 10:13:43 -0000
@@ -89,7 +89,7 @@ ParIterator num2pit(BufferView * bv, int
for ( ; num && pit != end; ++pit, --num)
;
-
+
if (pit != end)
return pit;
Index: src/insets/insetbibitem.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibitem.C,v
retrieving revision 1.37
diff -u -p -r1.37 insetbibitem.C
--- src/insets/insetbibitem.C 1 Nov 2003 15:45:15 -0000 1.37
+++ src/insets/insetbibitem.C 3 Nov 2003 10:13:43 -0000
@@ -53,7 +53,7 @@ InsetBibitem::~InsetBibitem()
auto_ptr<InsetBase> InsetBibitem::clone() const
{
- InsetBibitem * b = new InsetBibitem(params());
+ auto_ptr<InsetBibitem> b(new InsetBibitem(params()));
b->setCounter(counter);
return auto_ptr<InsetBase>(b);
}
Index: src/insets/insetexternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v
retrieving revision 1.128
diff -u -p -r1.128 insetexternal.C
--- src/insets/insetexternal.C 1 Nov 2003 15:45:15 -0000 1.128
+++ src/insets/insetexternal.C 3 Nov 2003 10:13:44 -0000
@@ -580,8 +580,8 @@ void InsetExternal::setParams(InsetExter
case RENDERBUTTON: {
RenderButton * button_ptr = renderer_->asButton();
if (!button_ptr) {
- button_ptr = new RenderButton;
- renderer_.reset(button_ptr);
+ renderer_.reset(new RenderButton);
+ button_ptr = renderer_->asButton();
}
button_ptr->update(getScreenLabel(params_, buffer), true);
@@ -590,10 +590,10 @@ void InsetExternal::setParams(InsetExter
} case RENDERGRAPHIC: {
RenderGraphic * graphic_ptr = renderer_->asGraphic();
if (!graphic_ptr) {
- graphic_ptr = new RenderGraphic;
+ renderer_.reset(new RenderGraphic);
+ graphic_ptr = renderer_->asGraphic();
graphic_ptr->connect(
boost::bind(&InsetExternal::statusChanged, this));
- renderer_.reset(graphic_ptr);
}
graphic_ptr->update(get_grfx_params(params_));
@@ -604,12 +604,12 @@ void InsetExternal::setParams(InsetExter
RenderMonitoredPreview * preview_ptr =
renderer_->asMonitoredPreview();
if (!preview_ptr) {
- preview_ptr = new RenderMonitoredPreview;
+ renderer_.reset(new RenderMonitoredPreview);
+ preview_ptr = renderer_->asMonitoredPreview();
preview_ptr->connect(
boost::bind(&InsetExternal::statusChanged, this));
preview_ptr->fileChanged(
boost::bind(&InsetExternal::fileChanged, this));
- renderer_.reset(preview_ptr);
}
if (preview_ptr->monitoring())
Index: src/insets/insethfill.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insethfill.C,v
retrieving revision 1.12
diff -u -p -r1.12 insethfill.C
--- src/insets/insethfill.C 31 Oct 2003 18:45:38 -0000 1.12
+++ src/insets/insethfill.C 3 Nov 2003 10:13:44 -0000
@@ -33,7 +33,7 @@ void InsetHFill::metrics(MetricsInfo &,
dim.wid = 3;
dim.asc = 3;
dim.des = 3;
- dim_ = dim;
+ dim_ = dim;
}
Index: src/insets/insetinclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v
retrieving revision 1.171
diff -u -p -r1.171 insetinclude.C
--- src/insets/insetinclude.C 1 Nov 2003 15:45:16 -0000 1.171
+++ src/insets/insetinclude.C 3 Nov 2003 10:13:44 -0000
@@ -402,7 +402,7 @@ int InsetInclude::linuxdoc(Buffer const
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
LatexRunParams runp = runparams;
- runp.nice = buffer.niceFile();
+ runp.nice = buffer.niceFile();
tmp->makeLinuxDocFile(writefile, runp, true);
}
Index: src/insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.361
diff -u -p -r1.361 insettabular.C
--- src/insets/insettabular.C 1 Nov 2003 15:45:16 -0000 1.361
+++ src/insets/insettabular.C 3 Nov 2003 10:13:44 -0000
@@ -61,7 +61,7 @@ int const ADD_TO_HEIGHT = 2;
int const ADD_TO_TABULAR_WIDTH = 2;
///
-LyXTabular * paste_tabular = 0;
+boost::scoped_ptr<LyXTabular> paste_tabular;
struct TabularFeature {
@@ -144,7 +144,7 @@ string const featureAsString(LyXTabular:
bool InsetTabular::hasPasteBuffer() const
{
- return (paste_tabular != 0);
+ return (paste_tabular.get() != 0);
}
@@ -1022,9 +1022,12 @@ InsetTabular::priv_dispatch(FuncRequest
++p;
}
maxCols = max(cols, maxCols);
- delete paste_tabular;
- paste_tabular = new LyXTabular(bv->buffer()->params(),
- this, rows, maxCols);
+
+ paste_tabular.reset(
+ new LyXTabular(bv->buffer()->params(),
+ this, rows, maxCols)
+ );
+
string::size_type op = 0;
int cell = 0;
int cells = paste_tabular->getNumberOfCells();
@@ -1060,8 +1063,7 @@ InsetTabular::priv_dispatch(FuncRequest
// so that the clipboard is used and it goes on
// to default
// and executes LFUN_PASTESELECTION in insettext!
- delete paste_tabular;
- paste_tabular = 0;
+ paste_tabular.reset();
}
}
case LFUN_PASTE:
@@ -2250,8 +2252,7 @@ bool InsetTabular::copySelection(BufferV
if (sel_row_start > sel_row_end)
swap(sel_row_start, sel_row_end);
- delete paste_tabular;
- paste_tabular = new LyXTabular(tabular);
+ paste_tabular.reset(new LyXTabular(tabular));
paste_tabular->setOwner(this);
for (int i = 0; i < sel_row_start; ++i)
@@ -2277,7 +2278,7 @@ bool InsetTabular::copySelection(BufferV
true, true);
ostringstream os;
- LatexRunParams const runparams;
+ LatexRunParams const runparams;
paste_tabular->ascii(*bv->buffer(), os, runparams,
ownerPar(*bv->buffer(), this).params().depth(), true, '\t');
bv->stuffClipboard(os.str());
@@ -2636,11 +2637,12 @@ bool InsetTabular::insertAsciiString(Buf
int ocol = 0;
int row = 0;
if (usePaste) {
- delete paste_tabular;
- paste_tabular = new LyXTabular(bv->buffer()->params(),
- rows, maxCols);
+ paste_tabular.reset(
+ new LyXTabular(bv->buffer()->params(), rows, maxCols)
+ );
+
paste_tabular->setOwner(this);
- loctab = paste_tabular;
+ loctab = paste_tabular.get();
cols = 0;
} else {
loctab = &tabular;
Index: src/insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.521
diff -u -p -r1.521 insettext.C
--- src/insets/insettext.C 1 Nov 2003 15:45:17 -0000 1.521
+++ src/insets/insettext.C 3 Nov 2003 10:13:45 -0000
@@ -858,7 +858,8 @@ InsetText::priv_dispatch(FuncRequest con
result = DispatchResult(true);
} else {
replaceSelection(bv->getLyXText());
- text_.insertInset(new InsetNewline);
+ auto_ptr<InsetNewline> ins(new InsetNewline);
+ text_.insertInset(ins.release());
updflag = true;
}
break;
Index: src/insets/insettheorem.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettheorem.C,v
retrieving revision 1.23
diff -u -p -r1.23 insettheorem.C
--- src/insets/insettheorem.C 16 Sep 2003 15:39:33 -0000 1.23
+++ src/insets/insettheorem.C 3 Nov 2003 10:13:45 -0000
@@ -56,14 +56,14 @@ void InsetTheorem::write(Buffer const *
}
-InsetBase * InsetTheorem::clone() const
+auto_ptr<InsetBase> InsetTheorem::clone() const
{
#ifdef WITH_WARNINGS
#warning Is this inset used? If YES this is WRONG!!! (Jug)
#endif
- InsetTheorem * result = new InsetTheorem;
-
+ auto_ptr<InsetTheorem> result(new InsetTheorem);
result->setCollapsed(!isOpen());
+
return result;
}
Index: src/insets/render_base.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/render_base.h,v
retrieving revision 1.3
diff -u -p -r1.3 render_base.h
--- src/insets/render_base.h 25 Oct 2003 20:09:52 -0000 1.3
+++ src/insets/render_base.h 3 Nov 2003 10:13:45 -0000
@@ -14,6 +14,8 @@
#include "dimension.h"
+#include <memory>
+
class MetricsInfo;
class PainterInfo;
@@ -26,7 +28,7 @@ class RenderBase {
public:
virtual ~RenderBase() {}
- virtual RenderBase * clone() const = 0;
+ virtual std::auto_ptr<RenderBase> clone() const = 0;
/// compute the size of the object returned in dim
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
Index: src/insets/render_button.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/render_button.C,v
retrieving revision 1.2
diff -u -p -r1.2 render_button.C
--- src/insets/render_button.C 12 Oct 2003 18:54:11 -0000 1.2
+++ src/insets/render_button.C 3 Nov 2003 10:13:45 -0000
@@ -19,6 +19,7 @@
#include "frontends/Painter.h"
using std::string;
+using std::auto_ptr;
RenderButton::RenderButton()
@@ -26,9 +27,9 @@ RenderButton::RenderButton()
{}
-RenderBase * RenderButton::clone() const
+auto_ptr<RenderBase> RenderButton::clone() const
{
- return new RenderButton(*this);
+ return auto_ptr<RenderBase>(new RenderButton(*this));
}
Index: src/insets/render_button.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/render_button.h,v
retrieving revision 1.2
diff -u -p -r1.2 render_button.h
--- src/insets/render_button.h 25 Oct 2003 20:09:52 -0000 1.2
+++ src/insets/render_button.h 3 Nov 2003 10:13:45 -0000
@@ -22,7 +22,7 @@ class RenderButton : public RenderBase
public:
RenderButton();
- RenderBase * clone() const;
+ std::auto_ptr<RenderBase> clone() const;
/// compute the size of the object returned in dim
virtual void metrics(MetricsInfo & mi, Dimension & dim) const;
Index: src/insets/render_graphic.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/render_graphic.C,v
retrieving revision 1.3
diff -u -p -r1.3 render_graphic.C
--- src/insets/render_graphic.C 22 Oct 2003 11:12:31 -0000 1.3
+++ src/insets/render_graphic.C 3 Nov 2003 10:13:45 -0000
@@ -31,6 +31,7 @@ using lyx::support::AbsolutePath;
using lyx::support::OnlyFilename;
using std::string;
+using std::auto_ptr;
RenderGraphic::RenderGraphic()
@@ -46,9 +47,9 @@ RenderGraphic::RenderGraphic(RenderGraph
{}
-RenderBase * RenderGraphic::clone() const
+auto_ptr<RenderBase> RenderGraphic::clone() const
{
- return new RenderGraphic(*this);
+ return auto_ptr<RenderBase>(new RenderGraphic(*this));
}
@@ -80,7 +81,7 @@ boost::signals::connection RenderGraphic
namespace {
-
+
string const statusMessage(graphics::ImageStatus status)
{
switch (status) {
Index: src/insets/render_graphic.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/render_graphic.h,v
retrieving revision 1.3
diff -u -p -r1.3 render_graphic.h
--- src/insets/render_graphic.h 25 Oct 2003 20:09:52 -0000 1.3
+++ src/insets/render_graphic.h 3 Nov 2003 10:13:45 -0000
@@ -25,7 +25,7 @@ class RenderGraphic : public RenderBase
public:
RenderGraphic();
RenderGraphic(RenderGraphic const &);
- RenderBase * clone() const;
+ std::auto_ptr<RenderBase> clone() const;
/// compute the size of the object returned in dim
void metrics(MetricsInfo & mi, Dimension & dim) const;
Index: src/insets/render_preview.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/render_preview.C,v
retrieving revision 1.3
diff -u -p -r1.3 render_preview.C
--- src/insets/render_preview.C 22 Oct 2003 22:26:47 -0000 1.3
+++ src/insets/render_preview.C 3 Nov 2003 10:13:45 -0000
@@ -31,6 +31,7 @@
#include <boost/bind.hpp>
using std::string;
+using std::auto_ptr;
namespace graphics = lyx::graphics;
namespace support = lyx::support;
@@ -55,9 +56,9 @@ RenderPreview::RenderPreview(RenderPrevi
{}
-RenderBase * RenderPreview::clone() const
+auto_ptr<RenderBase> RenderPreview::clone() const
{
- return new RenderPreview(*this);
+ return auto_ptr<RenderBase>(new RenderPreview(*this));
}
Index: src/insets/render_preview.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/render_preview.h,v
retrieving revision 1.4
diff -u -p -r1.4 render_preview.h
--- src/insets/render_preview.h 25 Oct 2003 20:09:52 -0000 1.4
+++ src/insets/render_preview.h 3 Nov 2003 10:13:45 -0000
@@ -46,7 +46,7 @@ public:
RenderPreview();
RenderPreview(RenderPreview const &);
- RenderBase * clone() const;
+ std::auto_ptr<RenderBase> clone() const;
/// Compute the size of the object, returned in dim
void metrics(MetricsInfo &, Dimension & dim) const;
Index: src/mathed/formulamacro.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.C,v
retrieving revision 1.144
diff -u -p -r1.144 formulamacro.C
--- src/mathed/formulamacro.C 31 Oct 2003 18:45:42 -0000 1.144
+++ src/mathed/formulamacro.C 3 Nov 2003 10:13:45 -0000
@@ -114,9 +114,9 @@ void InsetFormulaMacro::read(Buffer cons
void InsetFormulaMacro::read(std::istream & is)
{
- MathMacroTemplate * p = new MathMacroTemplate(is);
+ auto_ptr<MathMacroTemplate> p(new MathMacroTemplate(is));
setInsetName(p->name());
- MathMacroTable::create(MathAtom(p));
+ MathMacroTable::create(MathAtom(p.release()));
//metrics();
}
Index: src/mathed/math_extern.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_extern.C,v
retrieving revision 1.63
diff -u -p -r1.63 math_extern.C
--- src/mathed/math_extern.C 6 Oct 2003 15:43:13 -0000 1.63
+++ src/mathed/math_extern.C 3 Nov 2003 10:13:45 -0000
@@ -47,7 +47,7 @@ using lyx::support::subst;
using std::string;
using std::endl;
using std::find_if;
-
+using std::auto_ptr;
using std::istringstream;
using std::ostream;
using std::ostringstream;
@@ -289,13 +289,13 @@ void splitScripts(MathArray & ar)
// create extra script inset and move superscript over
MathScriptInset * p = ar[i].nucleus()->asScriptInset();
- MathScriptInset * q = new MathScriptInset(true);
+ auto_ptr<MathScriptInset> q(new MathScriptInset(true));
std::swap(q->up(), p->up());
p->removeScript(true);
// insert new inset behind
++i;
- ar.insert(i, MathAtom(q));
+ ar.insert(i, MathAtom(q.release()));
}
//lyxerr << "\nScripts to: " << ar << endl;
}
@@ -464,13 +464,13 @@ void extractFunctions(MathArray & ar)
extractScript(exp, jt, ar.end());
// create a proper inset as replacement
- MathExFuncInset * p = new MathExFuncInset(name);
+ auto_ptr<MathExFuncInset> p(new MathExFuncInset(name));
// jt points to the "argument". Get hold of this.
MathArray::iterator st = extractArgument(p->cell(0), jt, ar.end());
// replace the function name by a real function inset
- *it = MathAtom(p);
+ *it = MathAtom(p.release());
// remove the source of the argument from the array
ar.erase(it + 1, st);
@@ -540,7 +540,7 @@ void extractIntegrals(MathArray & ar)
continue;
// core ist part from behind the scripts to the 'd'
- MathExIntInset * p = new MathExIntInset("int");
+ auto_ptr<MathExIntInset> p(new MathExIntInset("int"));
// handle scripts if available
if (!testIntSymbol(*it)) {
@@ -554,7 +554,7 @@ void extractIntegrals(MathArray & ar)
// remove used parts
ar.erase(it + 1, tt);
- *it = MathAtom(p);
+ *it = MathAtom(p.release());
}
//lyxerr << "\nIntegrals to: " << ar << endl;
}
@@ -604,7 +604,7 @@ void extractSums(MathArray & ar)
continue;
// create a proper inset as replacement
- MathExIntInset * p = new MathExIntInset("sum");
+ auto_ptr<MathExIntInset> p(new MathExIntInset("sum"));
// collect lower bound and summation index
MathScriptInset const * sub = ar[i]->asScriptInset();
@@ -633,7 +633,7 @@ void extractSums(MathArray & ar)
// cleanup
ar.erase(it + 1, tt);
- *it = MathAtom(p);
+ *it = MathAtom(p.release());
}
//lyxerr << "\nSums to: " << ar << endl;
}
@@ -682,7 +682,7 @@ void extractDiff(MathArray & ar)
}
// create a proper diff inset
- MathDiffInset * diff = new MathDiffInset;
+ auto_ptr<MathDiffInset> diff(new MathDiffInset);
// collect function, let jt point behind last used item
MathArray::iterator jt = it + 1;
@@ -731,7 +731,7 @@ void extractDiff(MathArray & ar)
// cleanup
ar.erase(it + 1, jt);
- *it = MathAtom(diff);
+ *it = MathAtom(diff.release());
}
//lyxerr << "\nDiffs to: " << ar << endl;
}
Index: src/mathed/math_parser.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v
retrieving revision 1.294
diff -u -p -r1.294 math_parser.C
--- src/mathed/math_parser.C 27 Oct 2003 17:22:27 -0000 1.294
+++ src/mathed/math_parser.C 3 Nov 2003 10:13:46 -0000
@@ -1165,7 +1165,7 @@ void Parser::parse1(MathGridInset & grid
// Disabled
else if (1 && t.cs() == "ar") {
- MathXYArrowInset * p = new MathXYArrowInset;
+ auto_ptr<MathXYArrowInset> p(new MathXYArrowInset);
// try to read target
parse(p->cell(0), FLAG_OTPTION, mode);
// try to read label
@@ -1176,7 +1176,7 @@ void Parser::parse1(MathGridInset & grid
//lyxerr << "read label: " << p->cell(1) << endl;
}
- cell->push_back(MathAtom(p));
+ cell->push_back(MathAtom(p.release()));
//lyxerr << "read cell: " << cell << endl;
}
#endif
Index: src/support/forkedcall.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.h,v
retrieving revision 1.14
diff -u -p -r1.14 forkedcall.h
--- src/support/forkedcall.h 6 Oct 2003 15:43:18 -0000 1.14
+++ src/support/forkedcall.h 3 Nov 2003 10:13:46 -0000
@@ -32,6 +32,8 @@
#include <sys/types.h>
+#include <memory>
+
namespace lyx {
namespace support {
@@ -50,7 +52,7 @@ public:
///
virtual ~ForkedProcess() {}
///
- virtual ForkedProcess * clone() const = 0;
+ virtual std::auto_ptr<ForkedProcess> clone() const = 0;
/** A SignalType signal is can be emitted once the forked process
* has finished. It passes:
@@ -139,8 +141,8 @@ private:
class Forkedcall : public ForkedProcess {
public:
///
- virtual ForkedProcess * clone() const {
- return new Forkedcall(*this);
+ virtual std::auto_ptr<ForkedProcess> clone() const {
+ return std::auto_ptr<ForkedProcess>(new Forkedcall(*this));
}
/** Start the child process.
Index: src/support/forkedcontr.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.C,v
retrieving revision 1.15
diff -u -p -r1.15 forkedcontr.C
--- src/support/forkedcontr.C 6 Oct 2003 15:43:18 -0000 1.15
+++ src/support/forkedcontr.C 3 Nov 2003 10:13:46 -0000
@@ -78,7 +78,7 @@ void ForkedcallsController::addCall(Fork
if (!timeout_->running())
timeout_->start();
- forkedCalls.push_back(newcall.clone());
+ forkedCalls.push_back(newcall.clone().release());
childrenChanged();
}
Index: src/support/getcwd.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/getcwd.C,v
retrieving revision 1.9
diff -u -p -r1.9 getcwd.C
--- src/support/getcwd.C 6 Oct 2003 15:43:18 -0000 1.9
+++ src/support/getcwd.C 3 Nov 2003 10:13:46 -0000
@@ -15,6 +15,9 @@
#include "support/lyxlib.h"
+#include <boost/scoped_array.hpp>
+
+using boost::scoped_array;
using std::string;
@@ -39,18 +42,17 @@ string const lyx::support::getcwd()
{
int n = 256; // Assume path is less than 256 chars
char * err;
- char * tbuf = new char[n];
+ scoped_array<char> tbuf(new char[n]);
// Safe. Hopefully all getcwds behave this way!
- while (((err = l_getcwd(tbuf, n)) == 0) && (errno == ERANGE)) {
+ while (((err = l_getcwd(tbuf.get(), n)) == 0) && (errno == ERANGE)) {
// Buffer too small, double the buffersize and try again
- delete[] tbuf;
- n = 2 * n;
- tbuf = new char[n];
+ n *= 2;
+ tbuf.reset(new char[n]);
}
string result;
- if (err) result = tbuf;
- delete[] tbuf;
+ if (err)
+ result = tbuf.get();
return result;
}
Index: src/support/os_os2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_os2.C,v
retrieving revision 1.9
diff -u -p -r1.9 os_os2.C
--- src/support/os_os2.C 23 Aug 2003 00:16:57 -0000 1.9
+++ src/support/os_os2.C 3 Nov 2003 10:13:46 -0000
@@ -21,6 +21,10 @@
#define INCL_DOSERRORS
#include <os2.h>
+#include <boost/scoped_array.hpp>
+
+using boost::scoped_array;
+
namespace {
string binpath_;
@@ -44,12 +48,12 @@ void init(int * argc, char ** argv[])
APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
if (rc != NO_ERROR)
exit(rc);
- char* tmp = new char[256];
+ scoped_array<char> tmp(new char[256]);
// This is the only reliable way to retrieve the executable name.
rc = DosQueryModuleName(ppib->pib_hmte, 256L, tmp);
if (rc != NO_ERROR)
exit(rc);
- string p = tmp;
+ string p = tmp.get();
p = slashify_path(p);
binname_ = OnlyFilename(p);
binname_.erase(binname_.length()-4, string::npos);
Index: src/support/tempname.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/tempname.C,v
retrieving revision 1.17
diff -u -p -r1.17 tempname.C
--- src/support/tempname.C 6 Oct 2003 15:43:21 -0000 1.17
+++ src/support/tempname.C 3 Nov 2003 10:13:46 -0000
@@ -19,6 +19,10 @@
#include "debug.h"
#include "os.h"
+#include <boost/scoped_array.hpp>
+
+using boost::scoped_array;
+
using std::string;
using std::endl;
@@ -49,15 +53,14 @@ string const lyx::support::tempName(stri
tmpfl += "XXXXXX";
// The supposedly safe mkstemp version
- char * tmpl = new char[tmpfl.length() + 1]; // + 1 for '\0'
- tmpfl.copy(tmpl, string::npos);
+ scoped_array<char> tmpl(new char[tmpfl.length() + 1]); // + 1 for '\0'
+ tmpfl.copy(tmpl.get(), string::npos);
tmpl[tmpfl.length()] = '\0'; // terminator
- int const tmpf = make_tempfile(tmpl);
+ int const tmpf = make_tempfile(tmpl.get());
if (tmpf != -1) {
- string const t(tmpl);
+ string const t(tmpl.get());
::close(tmpf);
- delete [] tmpl;
lyxerr[Debug::FILES] << "Temporary file `" << t
<< "' created." << endl;
return t;
@@ -65,7 +68,6 @@ string const lyx::support::tempName(stri
lyxerr[Debug::FILES]
<< "LyX Error: Unable to create temporary file."
<< endl;
- delete [] tmpl;
return string();
}
}
Index: src/tex2lyx/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/text.C,v
retrieving revision 1.25
diff -u -p -r1.25 text.C
--- src/tex2lyx/text.C 23 Oct 2003 11:46:33 -0000 1.25
+++ src/tex2lyx/text.C 3 Nov 2003 10:13:46 -0000
@@ -1075,7 +1075,7 @@ void parse_text(Parser & p, ostream & os
ss << '{' << p.verbatim_item() << "}\n";
handle_ert(os, ss.str(), context);
}
-
+
else if (t.cs() == "bibliographystyle") {
// store new bibliographystyle
bibliographystyle = p.verbatim_item();
--
Lgb