Bsongis/companion warning before automatic conversions (#4271)
* Does this work? * Warning before automatic conversions
This commit is contained in:
@@ -50,7 +50,11 @@ bool BinEepromFormat::write(const RadioData & radioData)
|
||||
{
|
||||
bool result;
|
||||
EEPROMInterface * eepromInterface = getCurrentEEpromInterface();
|
||||
uint8_t * eeprom = (uint8_t *)malloc(getEEpromSize(eepromInterface->getBoard()));
|
||||
int size = getEEpromSize(eepromInterface->getBoard());
|
||||
if (size == 0) {
|
||||
return false;
|
||||
}
|
||||
uint8_t * eeprom = (uint8_t *)malloc(size);
|
||||
int eeprom_size = eepromInterface->save(eeprom, radioData, 0, getCurrentFirmware()->getVariantNumber());
|
||||
if (eeprom_size) {
|
||||
result = writeToFile(eeprom, eeprom_size);
|
||||
@@ -91,6 +95,7 @@ bool BinEepromFormat::extract(RadioData & radioData, const QByteArray & eeprom)
|
||||
if (errors.test(HAS_WARNINGS)) {
|
||||
// TODO ShowEepromWarnings(this, QObject::tr("Warning"), errors.to_ulong());
|
||||
}
|
||||
board = eepromInterface->getBoard();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -29,9 +29,12 @@ bool CategorizedStorageFormat::load(RadioData & radioData)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!loadRadioSettingsFromByteArray(radioData.generalSettings, radioSettingsBuffer)) {
|
||||
OpenTxEepromInterface * loadInterface = loadRadioSettingsFromByteArray(radioData.generalSettings, radioSettingsBuffer);
|
||||
if (!loadInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
board = loadInterface->getBoard();
|
||||
|
||||
QByteArray modelsListBuffer;
|
||||
if (!loadFile(modelsListBuffer, "RADIO/models.txt")) {
|
||||
|
||||
@@ -75,6 +75,7 @@ bool Storage::load(RadioData & radioData)
|
||||
foreach(StorageFactory * factory, registeredStorageFactories) {
|
||||
StorageFormat * format = factory->instance(filename);
|
||||
if (format->load(radioData)) {
|
||||
board = format->getBoard();
|
||||
setWarning(format->warning());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ class StorageFormat
|
||||
public:
|
||||
StorageFormat(const QString & filename, uint8_t version=0):
|
||||
filename(filename),
|
||||
version(version)
|
||||
version(version),
|
||||
board(BOARD_UNKNOWN)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -61,6 +62,10 @@ class StorageFormat
|
||||
|
||||
virtual QString name() = 0;
|
||||
|
||||
virtual BoardEnum getBoard() {
|
||||
return board;
|
||||
}
|
||||
|
||||
protected:
|
||||
void setError(const QString & error)
|
||||
{
|
||||
@@ -78,6 +83,7 @@ class StorageFormat
|
||||
uint8_t version;
|
||||
QString _error;
|
||||
QString _warning;
|
||||
BoardEnum board;
|
||||
};
|
||||
|
||||
class StorageFactory
|
||||
|
||||
Reference in New Issue
Block a user