Skip to content

Commit

Permalink
Work around enchant_get_prefix_dir which is not available anymore in …
Browse files Browse the repository at this point in the history
…recent enchant
  • Loading branch information
manisandro committed Jun 13, 2024
1 parent 6a08133 commit e72d657
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 0 additions & 7 deletions gtk/src/Config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "Utils.hh"
#include "OutputEditorText.hh"

#include <enchant-provider.h>
#define USE_STD_NAMESPACE
#include <tesseract/baseapi.h>
#if TESSERACT_MAJOR_VERSION < 5
Expand Down Expand Up @@ -214,13 +213,7 @@ void Config::openSpellingDir() {

std::string Config::spellingLocation(Location location) {
if(location == SystemLocation) {
#ifdef G_OS_WIN32
std::string dataDir = Glib::build_filename(pkgDir, "share");
#else
char* prefix = enchant_get_prefix_dir();
std::string dataDir = Glib::build_filename(prefix, "share");
free(prefix);
#endif
#if HAVE_ENCHANT2
if(Gio::File::create_for_path(Glib::build_filename(dataDir, "myspell"))->query_exists()) {
return Glib::build_filename(dataDir, "myspell");
Expand Down
10 changes: 6 additions & 4 deletions qt/src/Config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

#include <QDesktopServices>
#include <QDir>
#include <QLibraryInfo>
#include <QMultiMap>
#include <QStandardPaths>
#include <QUrl>
#include <enchant-provider.h>
#define USE_STD_NAMESPACE
#include <tesseract/baseapi.h>
#if TESSERACT_MAJOR_VERSION < 5
Expand Down Expand Up @@ -200,9 +200,11 @@ QString Config::spellingLocation(Location location) {
#ifdef Q_OS_WIN
QDir dataDir = QDir(QString("%1/../share/").arg(QApplication::applicationDirPath()));
#else
char* prefix = enchant_get_prefix_dir();
QDir dataDir(QDir(prefix).absoluteFilePath("share"));
free(prefix);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDir dataDir = QDir(QString("%1/share/").arg(QLibraryInfo::path(QLibraryInfo::PrefixPath)));
#else
QDir dataDir = QDir(QString("%1/share/").arg(QLibraryInfo::location(QLibraryInfo::PrefixPath)));
#endif
#endif
#if HAVE_ENCHANT2
if(QDir(dataDir.absoluteFilePath("myspell")).exists()) {
Expand Down

0 comments on commit e72d657

Please sign in to comment.