Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Parsers/CppParser/cppdocumentprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
#include "cppparserconstants.h"

#include <cplusplus/Overview.h>
#include <cppeditor/cppeditordocument.h>
#include <cppeditor/cppdoxygen.h>
#include <cppeditor/cppeditordocument.h>
#include <cppeditor/cppmodelmanager.h>
#include <cppeditor/editordocumenthandle.h>

using namespace SpellChecker;
using namespace SpellChecker::CppSpellChecker::Internal;
Expand Down
19 changes: 11 additions & 8 deletions src/SpellCheckers/HunspellChecker/hunspellchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
#include <QFile>
#include <QFileInfo>
#include <QMutex>
#include <QSharedPointer>
#include <QTextCodec>
#include <QRegularExpression>
#include <QSharedPointer>
#include <QStringConverter>

#include <memory>
#include <string>
Expand All @@ -56,7 +56,8 @@ class HunspellWrapper
/* Get the affix dictionary path */
QString affPath = QString( dictionary ).replace( QRegularExpression("\\.dic$"), ".aff");
d_hunspell = HunspellPtr( new ::Hunspell( affPath.toLatin1(), dictionary.toLatin1() ) );
d_codec = QTextCodec::codecForName( d_hunspell->get_dic_encoding() );
d_decoder = QStringDecoder{ d_hunspell->get_dic_encoding() };
d_encoder = QStringEncoder{ d_hunspell->get_dic_encoding() };
}
/*! \brief Check if the supplied \a word is a spelling mistake or not.
*
Expand Down Expand Up @@ -110,8 +111,9 @@ class HunspellWrapper
* its Latin-1 representation. */
std::string encode( const QString& word ) const
{
if( d_codec != nullptr ) {
return d_codec->fromUnicode( word ).toStdString();
if ( d_encoder.isValid() ) {
QByteArray encoded = d_encoder( word );
return encoded.toStdString();
}
return word.toLatin1().toStdString();
}
Expand All @@ -126,16 +128,17 @@ class HunspellWrapper
* its Latin-1 representation. */
QString decode( const std::string& word ) const
{
if( d_codec != nullptr ) {
return d_codec->toUnicode( word.c_str(), word.size() );
if ( d_decoder.isValid() ) {
return d_decoder.decode( QByteArrayView{ word.c_str(), static_cast<qsizetype>( word.size() ) } );
}
return QLatin1String( word );
}

private:
using HunspellPtr = QSharedPointer< ::Hunspell>;
HunspellPtr d_hunspell;
QTextCodec* d_codec;
mutable QStringDecoder d_decoder;
mutable QStringEncoder d_encoder;
mutable QMutex d_mutex;
};

Expand Down