mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Essentially Lars' "thread safe" patch
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3183 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7aebbe6e10
commit
c9541eeeab
@ -1,15 +1,12 @@
|
||||
/*
|
||||
* File: math_inset.C
|
||||
* Purpose: Implementation of insets for mathed
|
||||
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
||||
* Created: January 1996
|
||||
* Description:
|
||||
* File: math_atom.C
|
||||
* Purpose: Wrapper for MathInset *
|
||||
* Author: André Pönitz
|
||||
* Created: July 2001
|
||||
*
|
||||
* Dependencies: Xlib, XForms
|
||||
* Copyright: 2001 The LyX team
|
||||
*
|
||||
* Copyright: 1996, 1997 Alejandro Aguilar Sierra
|
||||
*
|
||||
* Version: 0.8beta.
|
||||
* Version: 1.2.0
|
||||
*
|
||||
* You are free to use and modify this code under the terms of
|
||||
* the GNU General Public Licence version 2 or later.
|
||||
@ -23,6 +20,7 @@
|
||||
#include "math_inset.h"
|
||||
#include "support/LAssert.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
MathAtom::MathAtom()
|
||||
: nucleus_(0)
|
||||
@ -35,46 +33,31 @@ MathAtom::MathAtom(MathInset * p)
|
||||
|
||||
|
||||
MathAtom::MathAtom(MathAtom const & p)
|
||||
{
|
||||
copy(p);
|
||||
}
|
||||
: nucleus_(p.nucleus_ ? p.nucleus_->clone() : 0)
|
||||
{}
|
||||
|
||||
|
||||
void MathAtom::operator=(MathAtom const & p)
|
||||
{
|
||||
if (this == &p)
|
||||
if (&p == this)
|
||||
return;
|
||||
done();
|
||||
copy(p);
|
||||
MathAtom tmp(p);
|
||||
std::swap(tmp.nucleus_, nucleus_);
|
||||
}
|
||||
|
||||
|
||||
MathAtom::~MathAtom()
|
||||
{
|
||||
done();
|
||||
delete nucleus_;
|
||||
}
|
||||
|
||||
|
||||
void MathAtom::reset(MathInset * p)
|
||||
{
|
||||
done();
|
||||
nucleus_ = p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MathAtom::done()
|
||||
{
|
||||
if (p == nucleus_)
|
||||
return;
|
||||
delete nucleus_;
|
||||
}
|
||||
|
||||
|
||||
void MathAtom::copy(MathAtom const & p)
|
||||
{
|
||||
//cerr << "calling MathAtom::copy\n";
|
||||
nucleus_ = p.nucleus_;
|
||||
if (nucleus_)
|
||||
nucleus_ = nucleus_->clone();
|
||||
nucleus_ = p;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,10 @@ Ok: Implementing it thusly is not feasible since cursor movement gets
|
||||
hackish. We use MathAtom only as a wrapper around MathInset * with value
|
||||
semantics.
|
||||
|
||||
The MathAtom owns the MathInset * and is responsible for proper cloning and
|
||||
destruction. Every MathInset * should be put into a MathAtom after its
|
||||
creation as soon as possible.
|
||||
|
||||
Andre'
|
||||
|
||||
*/
|
||||
@ -30,31 +34,27 @@ class MathInset;
|
||||
|
||||
class MathAtom {
|
||||
public:
|
||||
///
|
||||
/// default constructor, object is useless, but we need it to put it into
|
||||
// std::containers
|
||||
MathAtom();
|
||||
///
|
||||
MathAtom(MathAtom const &);
|
||||
///
|
||||
/// the "real constructor"
|
||||
explicit MathAtom(MathInset * p);
|
||||
///
|
||||
virtual ~MathAtom();
|
||||
///
|
||||
/// copy constructor, invokes nucleus_->clone()
|
||||
MathAtom(MathAtom const &);
|
||||
/// we really need to clean up
|
||||
~MathAtom();
|
||||
/// assignment invokes nucleus_->clone()
|
||||
void operator=(MathAtom const &);
|
||||
///
|
||||
/// change inset under the hood
|
||||
void reset(MathInset * p);
|
||||
///
|
||||
/// access to the inset
|
||||
MathInset * nucleus() const;
|
||||
///
|
||||
/// access to the inset
|
||||
MathInset * operator->() const;
|
||||
|
||||
private:
|
||||
///
|
||||
MathInset * nucleus_;
|
||||
|
||||
/// raw copy
|
||||
void copy(MathAtom const & p);
|
||||
/// raw destruction
|
||||
void done();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user