diff --git a/avogadro/qtplugins/openbabel/obprocess.cpp b/avogadro/qtplugins/openbabel/obprocess.cpp index 4da2c6fb0..84bd7fd5f 100644 --- a/avogadro/qtplugins/openbabel/obprocess.cpp +++ b/avogadro/qtplugins/openbabel/obprocess.cpp @@ -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); }