Remove usage of QTextCodec in Hydrogen Import plugin (#7562)
* Remove QTextCodec QTextCodec was removed from Qt6 and is only available through the Qt5Compat module. QTextCodec was only used by the HydrogenImport plugin when importing old Hydrogen files that were saved using TinyXML before it supported UTF-8. HydrogenImport would use QTextCodec to try to get the current encoding from the locale, and then use that as a best guess for interpreting the XML data in the unspecified encoding it was saved in. None of this was ever reliable, since the encoding of the computer that saved the Hydrogen file might not be the same as the computer running LMMS and importing that file. There is no good solution here, so I decided to simply assume the old Hydrogen files are UTF-8 encoded. The worst that can happen is someone's ancient Hydrogen files containing non-ASCII text of some random encoding becomes mojibake'd after importing into LMMS, which is something that already could have happened. * Clean up a little
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
INCLUDE(BuildPlugin)
|
||||
|
||||
BUILD_PLUGIN(hydrogenimport HydrogenImport.cpp HydrogenImport.h local_file_mgr.cpp LocalFileMng.h)
|
||||
BUILD_PLUGIN(hydrogenimport HydrogenImport.cpp HydrogenImport.h LocalFileMng.cpp LocalFileMng.h)
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "HydrogenImport.h"
|
||||
|
||||
#include <QDomDocument>
|
||||
|
||||
#include "LocalFileMng.h"
|
||||
#include "HydrogenImport.h"
|
||||
#include "Song.h"
|
||||
#include "Engine.h"
|
||||
#include "Instrument.h"
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include <sys/stat.h>
|
||||
#include "LocalFileMng.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QFile>
|
||||
#include <QLocale>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "LocalFileMng.h"
|
||||
|
||||
namespace lmms
|
||||
{
|
||||
@@ -197,10 +196,7 @@ QDomDocument LocalFileMng::openXmlDocument( const QString& filename )
|
||||
return QDomDocument();
|
||||
|
||||
if( TinyXMLCompat ) {
|
||||
QString enc = QTextCodec::codecForLocale()->name();
|
||||
if( enc == QString("System") ) {
|
||||
enc = "UTF-8";
|
||||
}
|
||||
const QString enc = "UTF-8"; // unknown encoding, so assume utf-8 and call it a day
|
||||
QByteArray line;
|
||||
QByteArray buf = QString("<?xml version='1.0' encoding='%1' ?>\n")
|
||||
.arg( enc )
|
||||
@@ -14,12 +14,6 @@ namespace lmms
|
||||
class LocalFileMng
|
||||
{
|
||||
public:
|
||||
LocalFileMng();
|
||||
~LocalFileMng();
|
||||
std::vector<QString> getallPatternList(){
|
||||
return m_allPatternList;
|
||||
}
|
||||
|
||||
static QString readXmlString( QDomNode , const QString& nodeName, const QString& defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false);
|
||||
static float readXmlFloat( QDomNode , const QString& nodeName, float defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false);
|
||||
static int readXmlInt( QDomNode , const QString& nodeName, int defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false);
|
||||
@@ -27,7 +21,6 @@ public:
|
||||
static void convertFromTinyXMLString( QByteArray* str );
|
||||
static bool checkTinyXMLCompatMode( const QString& filename );
|
||||
static QDomDocument openXmlDocument( const QString& filename );
|
||||
std::vector<QString> m_allPatternList;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user