mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +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
|
* File: math_atom.C
|
||||||
* Purpose: Implementation of insets for mathed
|
* Purpose: Wrapper for MathInset *
|
||||||
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
* Author: André Pönitz
|
||||||
* Created: January 1996
|
* Created: July 2001
|
||||||
* Description:
|
|
||||||
*
|
*
|
||||||
* Dependencies: Xlib, XForms
|
* Copyright: 2001 The LyX team
|
||||||
*
|
*
|
||||||
* Copyright: 1996, 1997 Alejandro Aguilar Sierra
|
* Version: 1.2.0
|
||||||
*
|
|
||||||
* Version: 0.8beta.
|
|
||||||
*
|
*
|
||||||
* You are free to use and modify this code under the terms of
|
* You are free to use and modify this code under the terms of
|
||||||
* the GNU General Public Licence version 2 or later.
|
* the GNU General Public Licence version 2 or later.
|
||||||
@ -23,6 +20,7 @@
|
|||||||
#include "math_inset.h"
|
#include "math_inset.h"
|
||||||
#include "support/LAssert.h"
|
#include "support/LAssert.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
MathAtom::MathAtom()
|
MathAtom::MathAtom()
|
||||||
: nucleus_(0)
|
: nucleus_(0)
|
||||||
@ -35,46 +33,31 @@ MathAtom::MathAtom(MathInset * p)
|
|||||||
|
|
||||||
|
|
||||||
MathAtom::MathAtom(MathAtom const & p)
|
MathAtom::MathAtom(MathAtom const & p)
|
||||||
{
|
: nucleus_(p.nucleus_ ? p.nucleus_->clone() : 0)
|
||||||
copy(p);
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MathAtom::operator=(MathAtom const & p)
|
void MathAtom::operator=(MathAtom const & p)
|
||||||
{
|
{
|
||||||
if (this == &p)
|
if (&p == this)
|
||||||
return;
|
return;
|
||||||
done();
|
MathAtom tmp(p);
|
||||||
copy(p);
|
std::swap(tmp.nucleus_, nucleus_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathAtom::~MathAtom()
|
MathAtom::~MathAtom()
|
||||||
{
|
{
|
||||||
done();
|
delete nucleus_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathAtom::reset(MathInset * p)
|
void MathAtom::reset(MathInset * p)
|
||||||
{
|
{
|
||||||
done();
|
if (p == nucleus_)
|
||||||
nucleus_ = p;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MathAtom::done()
|
|
||||||
{
|
|
||||||
delete nucleus_;
|
delete nucleus_;
|
||||||
}
|
nucleus_ = p;
|
||||||
|
|
||||||
|
|
||||||
void MathAtom::copy(MathAtom const & p)
|
|
||||||
{
|
|
||||||
//cerr << "calling MathAtom::copy\n";
|
|
||||||
nucleus_ = p.nucleus_;
|
|
||||||
if (nucleus_)
|
|
||||||
nucleus_ = nucleus_->clone();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
hackish. We use MathAtom only as a wrapper around MathInset * with value
|
||||||
semantics.
|
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'
|
Andre'
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -30,31 +34,27 @@ class MathInset;
|
|||||||
|
|
||||||
class MathAtom {
|
class MathAtom {
|
||||||
public:
|
public:
|
||||||
///
|
/// default constructor, object is useless, but we need it to put it into
|
||||||
|
// std::containers
|
||||||
MathAtom();
|
MathAtom();
|
||||||
///
|
/// the "real constructor"
|
||||||
MathAtom(MathAtom const &);
|
|
||||||
///
|
|
||||||
explicit MathAtom(MathInset * p);
|
explicit MathAtom(MathInset * p);
|
||||||
///
|
/// copy constructor, invokes nucleus_->clone()
|
||||||
virtual ~MathAtom();
|
MathAtom(MathAtom const &);
|
||||||
///
|
/// we really need to clean up
|
||||||
|
~MathAtom();
|
||||||
|
/// assignment invokes nucleus_->clone()
|
||||||
void operator=(MathAtom const &);
|
void operator=(MathAtom const &);
|
||||||
///
|
/// change inset under the hood
|
||||||
void reset(MathInset * p);
|
void reset(MathInset * p);
|
||||||
///
|
/// access to the inset
|
||||||
MathInset * nucleus() const;
|
MathInset * nucleus() const;
|
||||||
///
|
/// access to the inset
|
||||||
MathInset * operator->() const;
|
MathInset * operator->() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
MathInset * nucleus_;
|
MathInset * nucleus_;
|
||||||
|
|
||||||
/// raw copy
|
|
||||||
void copy(MathAtom const & p);
|
|
||||||
/// raw destruction
|
|
||||||
void done();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user