mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-09 18:52:46 +00:00
Store the forked calls in boost::shared_ptr rather than a raw pointer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8518 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5a59ab2c37
commit
e942a15dd8
@ -1,3 +1,9 @@
|
|||||||
|
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>
|
2004-03-22 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* lyxfunc.C (getStatus): handle read-only buffers correctly;
|
* lyxfunc.C (getStatus): handle read-only buffers correctly;
|
||||||
|
@ -30,13 +30,14 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
using boost::shared_ptr;
|
||||||
|
|
||||||
#ifndef CXX_GLOBAL_CSTD
|
#ifndef CXX_GLOBAL_CSTD
|
||||||
using std::strcpy;
|
using std::strcpy;
|
||||||
using std::strlen;
|
using std::strlen;
|
||||||
using std::strpbrk;
|
using std::strpbrk;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::auto_ptr;
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::max;
|
using std::max;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -45,14 +46,15 @@ using std::string;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class LaunchIspell : public lyx::support::ForkedProcess {
|
class LaunchIspell : public lyx::support::ForkedProcess {
|
||||||
|
typedef lyx::support::ForkedProcess ForkedProcess;
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
LaunchIspell(BufferParams const & p, string const & l,
|
LaunchIspell(BufferParams const & p, string const & l,
|
||||||
int * in, int * out, int * err)
|
int * in, int * out, int * err)
|
||||||
: params(p), lang(l), pipein(in), pipeout(out), pipeerr(err) {}
|
: params(p), lang(l), pipein(in), pipeout(out), pipeerr(err) {}
|
||||||
///
|
///
|
||||||
virtual auto_ptr<lyx::support::ForkedProcess> clone() const {
|
virtual shared_ptr<ForkedProcess> clone() const {
|
||||||
return auto_ptr<lyx::support::ForkedProcess>(new LaunchIspell(*this));
|
return shared_ptr<ForkedProcess>(new LaunchIspell(*this));
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
int start();
|
int start();
|
||||||
|
10
src/lyx_cb.C
10
src/lyx_cb.C
@ -44,6 +44,8 @@
|
|||||||
#include "support/path_defines.h"
|
#include "support/path_defines.h"
|
||||||
#include "support/systemcall.h"
|
#include "support/systemcall.h"
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@ -71,7 +73,8 @@ using lyx::support::user_lyxdir;
|
|||||||
|
|
||||||
namespace os = lyx::support::os;
|
namespace os = lyx::support::os;
|
||||||
|
|
||||||
using std::auto_ptr;
|
using boost::shared_ptr;
|
||||||
|
|
||||||
using std::back_inserter;
|
using std::back_inserter;
|
||||||
using std::copy;
|
using std::copy;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -221,8 +224,9 @@ public:
|
|||||||
AutoSaveBuffer(BufferView & bv, string const & fname)
|
AutoSaveBuffer(BufferView & bv, string const & fname)
|
||||||
: bv_(bv), fname_(fname) {}
|
: bv_(bv), fname_(fname) {}
|
||||||
///
|
///
|
||||||
virtual auto_ptr<ForkedProcess> clone() const {
|
virtual shared_ptr<ForkedProcess> clone() const
|
||||||
return auto_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
|
{
|
||||||
|
return shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
int start();
|
int start();
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
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>
|
2004-03-22 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* forkedcontr.[Ch] (childrenChanged, getPIDs, getCommand): remove
|
* forkedcontr.[Ch] (childrenChanged, getPIDs, getCommand): remove
|
||||||
|
@ -32,8 +32,6 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace support {
|
namespace support {
|
||||||
|
|
||||||
@ -52,7 +50,7 @@ public:
|
|||||||
///
|
///
|
||||||
virtual ~ForkedProcess() {}
|
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
|
/** A SignalType signal is can be emitted once the forked process
|
||||||
* has finished. It passes:
|
* has finished. It passes:
|
||||||
@ -141,8 +139,8 @@ private:
|
|||||||
class Forkedcall : public ForkedProcess {
|
class Forkedcall : public ForkedProcess {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
virtual std::auto_ptr<ForkedProcess> clone() const {
|
virtual boost::shared_ptr<ForkedProcess> clone() const {
|
||||||
return std::auto_ptr<ForkedProcess>(new Forkedcall(*this));
|
return boost::shared_ptr<ForkedProcess>(new Forkedcall(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Start the child process.
|
/** Start the child process.
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "frontends/Timeout.h"
|
#include "frontends/Timeout.h"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/iterator/indirect_iterator.hpp>
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -65,11 +66,6 @@ ForkedcallsController::ForkedcallsController()
|
|||||||
// I want to print or something.
|
// I want to print or something.
|
||||||
ForkedcallsController::~ForkedcallsController()
|
ForkedcallsController::~ForkedcallsController()
|
||||||
{
|
{
|
||||||
for (ListType::iterator it = forkedCalls.begin();
|
|
||||||
it != forkedCalls.end(); ++it) {
|
|
||||||
delete *it;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete timeout_;
|
delete timeout_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +75,7 @@ void ForkedcallsController::addCall(ForkedProcess const & newcall)
|
|||||||
if (!timeout_->running())
|
if (!timeout_->running())
|
||||||
timeout_->start();
|
timeout_->start();
|
||||||
|
|
||||||
forkedCalls.push_back(newcall.clone().release());
|
forkedCalls.push_back(newcall.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +86,7 @@ void ForkedcallsController::timer()
|
|||||||
ListType::iterator it = forkedCalls.begin();
|
ListType::iterator it = forkedCalls.begin();
|
||||||
ListType::iterator end = forkedCalls.end();
|
ListType::iterator end = forkedCalls.end();
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
ForkedProcess * actCall = *it;
|
ForkedProcess * actCall = it->get();
|
||||||
|
|
||||||
pid_t pid = actCall->pid();
|
pid_t pid = actCall->pid();
|
||||||
int stat_loc;
|
int stat_loc;
|
||||||
@ -134,10 +130,8 @@ void ForkedcallsController::timer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (remove_it) {
|
if (remove_it) {
|
||||||
forkedCalls.erase(it);
|
|
||||||
|
|
||||||
actCall->emitSignal();
|
actCall->emitSignal();
|
||||||
delete actCall;
|
forkedCalls.erase(it);
|
||||||
|
|
||||||
/* start all over: emiting the signal can result
|
/* start all over: emiting the signal can result
|
||||||
* in changing the list (Ab)
|
* in changing the list (Ab)
|
||||||
@ -158,19 +152,21 @@ void ForkedcallsController::timer()
|
|||||||
// within tolerance secs
|
// within tolerance secs
|
||||||
void ForkedcallsController::kill(pid_t pid, int tolerance)
|
void ForkedcallsController::kill(pid_t pid, int tolerance)
|
||||||
{
|
{
|
||||||
ListType::iterator it =
|
typedef boost::indirect_iterator<ListType::iterator> iterator;
|
||||||
find_if(forkedCalls.begin(), forkedCalls.end(),
|
|
||||||
|
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));
|
lyx::compare_memfun(&Forkedcall::pid, pid));
|
||||||
|
|
||||||
if (it == forkedCalls.end())
|
if (it == end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(*it)->kill(tolerance);
|
it->kill(tolerance);
|
||||||
forkedCalls.erase(it);
|
forkedCalls.erase(it.base());
|
||||||
|
|
||||||
if (forkedCalls.empty()) {
|
if (forkedCalls.empty())
|
||||||
timeout_->stop();
|
timeout_->stop();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace support
|
} // namespace support
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
#ifndef FORKEDCONTR_H
|
#ifndef FORKEDCONTR_H
|
||||||
#define FORKEDCONTR_H
|
#define FORKEDCONTR_H
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <sys/types.h> // needed for pid_t
|
#include <sys/types.h> // needed for pid_t
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
class Timeout;
|
class Timeout;
|
||||||
@ -54,7 +54,8 @@ private:
|
|||||||
void timer();
|
void timer();
|
||||||
|
|
||||||
/// The child processes
|
/// The child processes
|
||||||
typedef std::list<ForkedProcess *> ListType;
|
typedef boost::shared_ptr<ForkedProcess> ForkedProcessPtr;
|
||||||
|
typedef std::list<ForkedProcessPtr> ListType;
|
||||||
///
|
///
|
||||||
ListType forkedCalls;
|
ListType forkedCalls;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user