+2004-03-23 Angus Leeming <leeming@lyx.org>
+
+ * ispell.C (LaunchIspell):
+ * lyx_cb.C (AutoSaveBuffer): change the signature of clone to return
+ a boost::shred_ptr rather than a std::auto_ptr.
+
2004-03-22 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* lyxfunc.C (getStatus): handle read-only buffers correctly;
#endif
#include <sys/time.h>
+using boost::shared_ptr;
+
#ifndef CXX_GLOBAL_CSTD
using std::strcpy;
using std::strlen;
using std::strpbrk;
#endif
-using std::auto_ptr;
using std::endl;
using std::max;
using std::string;
namespace {
class LaunchIspell : public lyx::support::ForkedProcess {
+ typedef lyx::support::ForkedProcess ForkedProcess;
public:
///
LaunchIspell(BufferParams const & p, string const & l,
int * in, int * out, int * err)
: params(p), lang(l), pipein(in), pipeout(out), pipeerr(err) {}
///
- virtual auto_ptr<lyx::support::ForkedProcess> clone() const {
- return auto_ptr<lyx::support::ForkedProcess>(new LaunchIspell(*this));
+ virtual shared_ptr<ForkedProcess> clone() const {
+ return shared_ptr<ForkedProcess>(new LaunchIspell(*this));
}
///
int start();
#include "support/path_defines.h"
#include "support/systemcall.h"
+#include <boost/shared_ptr.hpp>
+
#include <cerrno>
#include <fstream>
namespace os = lyx::support::os;
-using std::auto_ptr;
+using boost::shared_ptr;
+
using std::back_inserter;
using std::copy;
using std::endl;
AutoSaveBuffer(BufferView & bv, string const & fname)
: bv_(bv), fname_(fname) {}
///
- virtual auto_ptr<ForkedProcess> clone() const {
- return auto_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
+ virtual shared_ptr<ForkedProcess> clone() const
+ {
+ return shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
}
///
int start();
+2004-03-23 Angus Leeming <leeming@lyx.org>
+
+ * forkedcall.h (ForkedProcess, Forkedcall): change the signature of
+ clone to return a boost::shred_ptr rather than a std::auto_ptr.
+
+ * forkedcontr.[Ch]: store the forked calls as boost::shared_ptrs rather
+ than raw pointers.
+
2004-03-22 Angus Leeming <leeming@lyx.org>
* forkedcontr.[Ch] (childrenChanged, getPIDs, getCommand): remove
#include <sys/types.h>
-#include <memory>
-
namespace lyx {
namespace support {
///
virtual ~ForkedProcess() {}
///
- virtual std::auto_ptr<ForkedProcess> clone() const = 0;
+ virtual boost::shared_ptr<ForkedProcess> clone() const = 0;
/** A SignalType signal is can be emitted once the forked process
* has finished. It passes:
class Forkedcall : public ForkedProcess {
public:
///
- virtual std::auto_ptr<ForkedProcess> clone() const {
- return std::auto_ptr<ForkedProcess>(new Forkedcall(*this));
+ virtual boost::shared_ptr<ForkedProcess> clone() const {
+ return boost::shared_ptr<ForkedProcess>(new Forkedcall(*this));
}
/** Start the child process.
#include "frontends/Timeout.h"
#include <boost/bind.hpp>
+#include <boost/iterator/indirect_iterator.hpp>
#include <cerrno>
#include <cstdlib>
// I want to print or something.
ForkedcallsController::~ForkedcallsController()
{
- for (ListType::iterator it = forkedCalls.begin();
- it != forkedCalls.end(); ++it) {
- delete *it;
- }
-
delete timeout_;
}
if (!timeout_->running())
timeout_->start();
- forkedCalls.push_back(newcall.clone().release());
+ forkedCalls.push_back(newcall.clone());
}
ListType::iterator it = forkedCalls.begin();
ListType::iterator end = forkedCalls.end();
while (it != end) {
- ForkedProcess * actCall = *it;
+ ForkedProcess * actCall = it->get();
pid_t pid = actCall->pid();
int stat_loc;
}
if (remove_it) {
- forkedCalls.erase(it);
-
actCall->emitSignal();
- delete actCall;
+ forkedCalls.erase(it);
/* start all over: emiting the signal can result
* in changing the list (Ab)
// within tolerance secs
void ForkedcallsController::kill(pid_t pid, int tolerance)
{
- ListType::iterator it =
- find_if(forkedCalls.begin(), forkedCalls.end(),
- lyx::compare_memfun(&Forkedcall::pid, pid));
+ typedef boost::indirect_iterator<ListType::iterator> iterator;
+
+ iterator begin = boost::make_indirect_iterator(forkedCalls.begin());
+ iterator end = boost::make_indirect_iterator(forkedCalls.end());
+ iterator it = find_if(begin, end,
+ lyx::compare_memfun(&Forkedcall::pid, pid));
- if (it == forkedCalls.end())
+ if (it == end)
return;
- (*it)->kill(tolerance);
- forkedCalls.erase(it);
+ it->kill(tolerance);
+ forkedCalls.erase(it.base());
- if (forkedCalls.empty()) {
+ if (forkedCalls.empty())
timeout_->stop();
- }
}
} // namespace support
#ifndef FORKEDCONTR_H
#define FORKEDCONTR_H
+#include <boost/shared_ptr.hpp>
#include <sys/types.h> // needed for pid_t
-
#include <list>
class Timeout;
void timer();
/// The child processes
- typedef std::list<ForkedProcess *> ListType;
+ typedef boost::shared_ptr<ForkedProcess> ForkedProcessPtr;
+ typedef std::list<ForkedProcessPtr> ListType;
///
ListType forkedCalls;