X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_atom.C;h=a8e2815a0f146acfd65d18ebd5f2e069f4dfafcb;hb=c649284611c4198c9d70be8a16d153cdf1ec0700;hp=bcf72881cce99c386ffa57024577587021d6f221;hpb=ea35e1c460c3cbb4a9130aaeaed8e28dc0656961;p=lyx.git diff --git a/src/mathed/math_atom.C b/src/mathed/math_atom.C index bcf72881cc..a8e2815a0f 100644 --- a/src/mathed/math_atom.C +++ b/src/mathed/math_atom.C @@ -1,27 +1,27 @@ /* - * File: math_inset.C - * Purpose: Implementation of insets for mathed - * Author: Alejandro Aguilar Sierra - * 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. */ +#include + #ifdef __GNUG__ #pragma implementation #endif #include "math_atom.h" #include "math_inset.h" -#include "support/LAssert.h" + +#include MathAtom::MathAtom() @@ -34,58 +34,36 @@ MathAtom::MathAtom(MathInset * p) {} -MathAtom::MathAtom(MathAtom const & p) -{ - copy(p); -} +MathAtom::MathAtom(MathAtom const & at) + : nucleus_(at.nucleus_ ? at.nucleus_->clone() : 0) +{} -void MathAtom::operator=(MathAtom const & p) +void MathAtom::operator=(MathAtom const & at) { - if (this == &p) + if (&at == this) return; - done(); - copy(p); -} - - -MathAtom::~MathAtom() -{ - done(); + MathAtom tmp(at); + std::swap(tmp.nucleus_, nucleus_); } -void MathAtom::reset(MathInset * p) +void MathAtom::operator=(MathInset * p) { - done(); - nucleus_ = p; + reset(p); } - -void MathAtom::done() +MathAtom::~MathAtom() { delete nucleus_; } -void MathAtom::copy(MathAtom const & p) -{ - //cerr << "calling MathAtom::copy\n"; - nucleus_ = p.nucleus_; - if (nucleus_) - nucleus_ = nucleus_->clone(); -} - - -MathInset * MathAtom::nucleus() const -{ - lyx::Assert(nucleus_); - return nucleus_; -} - - -MathInset * MathAtom::operator->() const +void MathAtom::reset(MathInset * p) { - return nucleus(); + if (p == nucleus_) + return; + delete nucleus_; + nucleus_ = p; }