Skip to content

Commit

Permalink
Dynamically search for the data/plugins directories
Browse files Browse the repository at this point in the history
Search more dynamically for the Open Babel data/plugins directories,
and warn if we cannot find them.
  • Loading branch information
cryos committed Sep 2, 2015
1 parent fff9bf0 commit 38a9fbb
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions avogadro/qtplugins/openbabel/obprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,28 @@ OBProcess::OBProcess(QObject *parent_) :
env.insert("BABEL_DATADIR",
QCoreApplication::applicationDirPath() + "/data");
#else
// FIXME: Hardwiring a versioned subdirectory for now.
env.insert("BABEL_DATADIR",
QCoreApplication::applicationDirPath()
+ "/../share/openbabel/2.3.2");
env.insert("BABEL_LIBDIR",
QCoreApplication::applicationDirPath()
+ "/../lib/openbabel/2.3.2");
QDir dir(QCoreApplication::applicationDirPath() + "/../share/openbabel");
QStringList filters;
filters << "2.*";
QStringList dirs = dir.entryList(filters);
if (dirs.size() == 1) {
env.insert("BABEL_DATADIR",
QCoreApplication::applicationDirPath()
+ "/../share/openbabel/" + dirs[0]);
}
else {
qDebug() << "Error, Open Babel data directory not found.";
}
dir.setPath(QCoreApplication::applicationDirPath() + "/../lib/openbabel");
dirs = dir.entryList(filters);
if (dirs.size() == 1) {
env.insert("BABEL_LIBDIR",
QCoreApplication::applicationDirPath()
+ "/../lib/openbabel/" + dirs[0]);
}
else {
qDebug() << "Error, Open Babel plugins directory not found.";
}
#endif
m_process->setProcessEnvironment(env);
}
Expand Down

0 comments on commit 38a9fbb

Please sign in to comment.