Skip to content

Commit

Permalink
Merge pull request #1621 from ghutchis/fix-start-up-crash
Browse files Browse the repository at this point in the history
Fix crash at startup when opening a file from commandline
  • Loading branch information
ghutchis authored Feb 17, 2024
2 parents 509ca48 + 237adcf commit 0e71464
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 18 deletions.
21 changes: 17 additions & 4 deletions avogadro/qtgui/sceneplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,26 @@ class AVOGADROQTGUI_EXPORT ScenePlugin : public QObject
*/
virtual void setEnabled(bool enable);

/**
* @return the widget for plugin settings (e.g., colors, widths, etc.)
*/
virtual QWidget* setupWidget();
/**
* This method exists to query without creating the widget.
* @return true if the plugin has a setup widget
*/
virtual bool hasSetupWidget() const { return false; }

/**
* Returns if this plugin should be considered in the default behavior,
* or it should reset to true or false.
*/
enum DefaultBehavior { Ignore, False, True };
* Returns if this plugin should be considered in the default behavior,
* or it should reset to true or false.
*/
enum DefaultBehavior
{
Ignore,
False,
True
};
virtual DefaultBehavior defaultBehavior() const { return Ignore; }

signals:
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtgui/scenepluginmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ QVariant ScenePluginModel::data(const QModelIndex& index_, int role) const
switch (role) {
case Qt::DisplayRole:
case Qt::EditRole:
return (item->setupWidget() != nullptr) ? "•••" : " ";
return (item->hasSetupWidget()) ? "•••" : " ";
case Qt::ToolTipRole:
case Qt::WhatsThisRole:
return tr("Settings");
Expand Down
1 change: 1 addition & 0 deletions avogadro/qtplugins/ballandstick/ballandstick.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class BallAndStick : public QtGui::ScenePlugin
}

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

DefaultBehavior defaultBehavior() const override
{
Expand Down
6 changes: 5 additions & 1 deletion avogadro/qtplugins/cartoons/cartoons.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ class Cartoons : public QtGui::ScenePlugin
void process(const QtGui::Molecule& molecule,
Rendering::GroupNode& node) override;

QString name() const override { return tr("Cartoons", "protein ribbon / cartoon rendering"); }
QString name() const override
{
return tr("Cartoons", "protein ribbon / cartoon rendering");
}

QString description() const override
{
return tr("Display of biomolecule ribbons / cartoons.");
}

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

DefaultBehavior defaultBehavior() const override
{
Expand Down
16 changes: 10 additions & 6 deletions avogadro/qtplugins/closecontacts/closecontacts.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ class CloseContacts : public QtGui::ScenePlugin
void process(const QtGui::Molecule& molecule,
Rendering::GroupNode& node) override;

QString name() const override { return tr("Close Contacts", "rendering of non-covalent close contacts"); }
QString name() const override
{
return tr("Close Contacts", "rendering of non-covalent close contacts");
}

QString description() const override
{
return tr("Render close contacts between atoms.");
}

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

DefaultBehavior defaultBehavior() const override
{
Expand All @@ -47,10 +51,10 @@ public slots:

private:
std::string m_name = "Close Contacts";
const std::array<QString, 3> INTERACTION_NAMES = {
tr("Contact"), tr("Salt Bridge"), tr("Repulsive")
};

const std::array<QString, 3> INTERACTION_NAMES = { tr("Contact"),
tr("Salt Bridge"),
tr("Repulsive") };

std::array<double, 3> m_maximumDistances;
std::array<Vector3ub, 3> m_lineColors;
Expand Down
1 change: 1 addition & 0 deletions avogadro/qtplugins/crystal/crystalscene.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CrystalScene : public QtGui::ScenePlugin
}

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

private slots:
void setColor(const QColor& color);
Expand Down
2 changes: 2 additions & 0 deletions avogadro/qtplugins/label/label.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Label : public QtGui::ScenePlugin
}

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

void process(const QtGui::Molecule& molecule,
Rendering::GroupNode& node) override;

Expand Down
1 change: 1 addition & 0 deletions avogadro/qtplugins/meshes/meshes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Meshes : public QtGui::ScenePlugin
QString description() const override { return tr("Render polygon meshes."); }

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

DefaultBehavior defaultBehavior() const override
{
Expand Down
13 changes: 7 additions & 6 deletions avogadro/qtplugins/noncovalent/noncovalent.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class NonCovalent : public QtGui::ScenePlugin
{
return tr("Render a few non-covalent interactions.");
}

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

DefaultBehavior defaultBehavior() const override
{
Expand All @@ -48,11 +49,11 @@ public slots:

private:
const std::string m_name = "Non-Covalent";
const std::array<QString, 3> INTERACTION_NAMES = {
tr("Hydrogen"), tr("Halogen"), tr("Chalcogen")
};

const std::array<QString, 3> INTERACTION_NAMES = { tr("Hydrogen"),
tr("Halogen"),
tr("Chalcogen") };

std::array<double, 3> m_angleTolerancesDegrees;
std::array<double, 3> m_maximumDistances;
std::array<Vector3ub, 3> m_lineColors;
Expand Down
1 change: 1 addition & 0 deletions avogadro/qtplugins/wireframe/wireframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Wireframe : public QtGui::ScenePlugin
}

QWidget* setupWidget() override;
bool hasSetupWidget() const override { return true; }

DefaultBehavior defaultBehavior() const override
{
Expand Down

0 comments on commit 0e71464

Please sign in to comment.