printerEncoding: check if configured codec is available

This commit is contained in:
Siegfried Siegert 2023-11-24 09:32:00 +01:00
parent 539e392c0d
commit 3dac861ca0
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03

View File

@ -98,6 +98,16 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
// text encoding for printer // text encoding for printer
this->codec = QTextCodec::codecForName(printerEncoding); this->codec = QTextCodec::codecForName(printerEncoding);
if (this->codec == nullptr) {
printerEncoding = "ISO 8859-1";
qCritical() << "ATBDeviceControllerPlugin: ERROR: printer encoding \"" << printerEncoding << "\" is not supported!";
qCritical() << " ... use default encoding: " << printerEncoding;
this->codec = QTextCodec::codecForName(printerEncoding);
}
else {
qCritical() << "ATBDeviceControllerPlugin: Set printer encoding to " << printerEncoding;
}
this->diag->init(this->hw, this->eventReceiver); this->diag->init(this->hw, this->eventReceiver);
this->pluginState = PLUGIN_STATE::INITIALIZED; this->pluginState = PLUGIN_STATE::INITIALIZED;