Bsongis/companion warning before automatic conversions (#4271)

* Does this work?

* Warning before automatic conversions
This commit is contained in:
Bertrand Songis
2017-01-22 15:31:22 +01:00
committed by GitHub
parent 7a60714071
commit 285b8786b9
11 changed files with 64 additions and 29 deletions
+6 -1
View File
@@ -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 {
+4 -1
View File
@@ -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")) {
+1
View File
@@ -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;
}
+7 -1
View File
@@ -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