The rule-of-three says that if any of virtual destructor, copy constructor
or assignment operator needs to be manually implemented, then all three
should be implemented. Otherwise you can get subtle bugs which can be
difficult to find. In the changed classes, changing a copy-construction to
an assignment would have had surprising effects. Now they all behave
consistently.
+InsetCommand & InsetCommand::operator=(InsetCommand const & rhs)
+{
+ if (&rhs == this)
+ return *this;
+
+ Inset::operator=(rhs);
+ p_ = rhs.p_;
+ mouse_hover_.clear();
+ button_ = RenderButton();
+
+ return *this;
+}
+
+
InsetCommand::~InsetCommand()
{
if (p_.code() != NO_CODE)
InsetCommand::~InsetCommand()
{
if (p_.code() != NO_CODE)
///
InsetCommand(InsetCommand const & rhs);
///
///
InsetCommand(InsetCommand const & rhs);
///
+ InsetCommand & operator=(InsetCommand const & rhs);
+ ///
virtual ~InsetCommand();
///
InsetCommand * asInsetCommand() { return this; }
virtual ~InsetCommand();
///
InsetCommand * asInsetCommand() { return this; }
+InsetIPA & InsetIPA::operator=(InsetIPA const & other)
+{
+ if (&other == this)
+ return *this;
+
+ InsetText::operator=(other);
+ preview_.reset(new RenderPreview(*other.preview_, this));
+
+ return *this;
+}
+
+
void InsetIPA::write(ostream & os) const
{
os << "IPA" << "\n";
void InsetIPA::write(ostream & os) const
{
os << "IPA" << "\n";
~InsetIPA();
///
InsetIPA(InsetIPA const & other);
~InsetIPA();
///
InsetIPA(InsetIPA const & other);
+ ///
+ InsetIPA & operator=(InsetIPA const & other);
/// \name Methods inherited from Inset class
//@{
/// \name Methods inherited from Inset class
//@{
/// for including tex/lyx files
class InsetInclude : public InsetCommand {
/// for including tex/lyx files
class InsetInclude : public InsetCommand {
+ // Disable assignment operator, since it is not used, and cannot be
+ // implemented consistently with the copy constructor, because
+ // include_label is const.
+ InsetInclude & operator=(InsetInclude const &);
public:
///
InsetInclude(Buffer * buf, InsetCommandParams const &);
public:
///
InsetInclude(Buffer * buf, InsetCommandParams const &);
+InsetPreview & InsetPreview::operator=(InsetPreview const & other)
+{
+ if (&other == this)
+ return *this;
+
+ InsetText::operator=(other);
+ preview_.reset(new RenderPreview(*other.preview_, this));
+
+ return *this;
+}
+
+
void InsetPreview::write(ostream & os) const
{
os << "Preview" << "\n";
void InsetPreview::write(ostream & os) const
{
os << "Preview" << "\n";
~InsetPreview();
///
InsetPreview(InsetPreview const & other);
~InsetPreview();
///
InsetPreview(InsetPreview const & other);
+ ///
+ InsetPreview & operator=(InsetPreview const & other);
/// \name Methods inherited from Inset class
//@{
/// \name Methods inherited from Inset class
//@{