Commit 2665958a authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Add workaround for broken QtGui::Molecule copy constructor

Pull request with fix for it is pending:
https://github.com/OpenChemistry/avogadrolibs/pull/113
parent 877408c4
......@@ -164,23 +164,18 @@ void MoleculeDialog::loadMolecule(const QString &filename)
return;
}
// workaround for missing copy-constructor: fixed in Avogadro2 > 0.9
Avogadro::QtGui::Molecule tmpMol;
tmpMol = *IoWrapper::readMolecule(filename);
auto molecule = new Avogadro::QtGui::Molecule(tmpMol);
// Check that a valid molecule object was returned
if (!molecule) {
qCritical() << "Could not load molecule, aborting.";
return;
}
// 1. workaround for missing copy-constructor: fixed in Avogadro2 > 0.9
// 2. another workaround for broken copy-constructor that does not
// initialize the m_undoMolecule private member variable;
// this molecule should be created on the heap instead of the stack
m_molecule = *IoWrapper::readMolecule(filename);
if (molecule->atomCount() != 0) {
if (m_molecule.atomCount() != 0) {
disconnect(ui.glWidget->molecule(), 0, this, 0);
ui.glWidget->setMolecule(molecule);
ui.glWidget->setMolecule(&m_molecule);
ui.glWidget->update();
slotUpdateStatistics();
connect(molecule, &Avogadro::QtGui::Molecule::changed,
connect(&m_molecule, &Avogadro::QtGui::Molecule::changed,
this, &MoleculeDialog::slotUpdateStatistics);
}
ui.glWidget->resetCamera();
......
......@@ -16,6 +16,7 @@
#define MOLECULEVIEW_H
#include <kdialog.h>
#include <avogadro/qtgui/molecule.h>
#include "ui_moleculeviewerwidget.h"
......@@ -92,6 +93,11 @@ private slots:
/// Clears the view
void clearAllElementsInEditor();
private:
// workaround for broken copy-operator of QtGui::Molecule
// whould be removed after next Avogadro release greater 0.9
Avogadro::QtGui::Molecule m_molecule;
};
#endif // MOLECULEVIEW_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment