revise plugin loading logic
This commit is contained in:
@ -97,21 +97,26 @@ LammpsGui::LammpsGui(QWidget *parent, const QString &filename) :
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
plugin_path.clear();
|
plugin_path = settings.value("plugin_path", "liblammps.so").toString();
|
||||||
QString deffile = settings.value("plugin_path", "liblammps.so").toString();
|
if (!lammps.load_lib(plugin_path.toStdString().c_str())) {
|
||||||
for (const char *libfile : {deffile.toStdString().c_str(), "./liblammps.so", "liblammps.dylib",
|
// fall back to defaults
|
||||||
"./liblammps.dylib", "liblammps.dll"}) {
|
for (const char *libfile :
|
||||||
|
{"./liblammps.so", "liblammps.dylib", "./liblammps.dylib", "liblammps.dll"}) {
|
||||||
if (lammps.load_lib(libfile)) {
|
if (lammps.load_lib(libfile)) {
|
||||||
plugin_path = QFileInfo(libfile).canonicalFilePath();
|
plugin_path = QFileInfo(libfile).canonicalFilePath();
|
||||||
settings.setValue("plugin_path", plugin_path);
|
settings.setValue("plugin_path", plugin_path);
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
plugin_path.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin_path.isEmpty()) {
|
if (plugin_path.isEmpty()) {
|
||||||
// none of the plugin paths could load, remove key
|
// none of the plugin paths could load, remove key
|
||||||
settings.remove("plugin_path");
|
settings.remove("plugin_path");
|
||||||
QMessageBox::critical(this, "Error", "Cannot open LAMMPS shared library file.\n"
|
QMessageBox::critical(this, "Error",
|
||||||
|
"Cannot open LAMMPS shared library file.\n"
|
||||||
"Use -p command line flag to specify a path to the library.");
|
"Use -p command line flag to specify a path to the library.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -505,8 +510,7 @@ void LammpsGui::start_exe()
|
|||||||
void LammpsGui::update_recents(const QString &filename)
|
void LammpsGui::update_recents(const QString &filename)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
if (settings.contains("recent"))
|
if (settings.contains("recent")) recent = settings.value("recent").value<QList<QString>>();
|
||||||
recent = settings.value("recent").value<QList<QString>>();
|
|
||||||
|
|
||||||
for (int i = 0; i < recent.size(); ++i) {
|
for (int i = 0; i < recent.size(); ++i) {
|
||||||
QFileInfo fi(recent[i]);
|
QFileInfo fi(recent[i]);
|
||||||
@ -518,8 +522,10 @@ void LammpsGui::update_recents(const QString &filename)
|
|||||||
|
|
||||||
if (!filename.isEmpty() && !recent.contains(filename)) recent.prepend(filename);
|
if (!filename.isEmpty() && !recent.contains(filename)) recent.prepend(filename);
|
||||||
if (recent.size() > 5) recent.removeLast();
|
if (recent.size() > 5) recent.removeLast();
|
||||||
if (recent.size() > 0) settings.setValue("recent", QVariant::fromValue(recent));
|
if (recent.size() > 0)
|
||||||
else settings.remove("recent");
|
settings.setValue("recent", QVariant::fromValue(recent));
|
||||||
|
else
|
||||||
|
settings.remove("recent");
|
||||||
|
|
||||||
ui->action_1->setVisible(false);
|
ui->action_1->setVisible(false);
|
||||||
if ((recent.size() > 0) && !recent[0].isEmpty()) {
|
if ((recent.size() > 0) && !recent[0].isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user