Skip to content

Commit

Permalink
Fix segfault when selected channel disappears
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Aug 21, 2024
1 parent 25691ce commit f113ef9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions application/applicationupdateregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ const QString ApplicationUpdateRegistry::updateChannel() const
{
return globalPrefs->applicationUpdateChannel();
}

void ApplicationUpdateRegistry::setUpdateChannel(const QString &newUpdateChannel) const
{
globalPrefs->setApplicationUpdateChannel(newUpdateChannel);
}
1 change: 1 addition & 0 deletions application/applicationupdateregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ApplicationUpdateRegistry : public Flipper::UpdateRegistry

private:
const QString updateChannel() const override;
void setUpdateChannel(const QString &newUpdateChannel) const override;
};


5 changes: 5 additions & 0 deletions backend/firmwareupdateregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ const QString FirmwareUpdateRegistry::updateChannel() const
{
return globalPrefs->firmwareUpdateChannel();
}

void FirmwareUpdateRegistry::setUpdateChannel(const QString &newUpdateChannel) const
{
globalPrefs->setFirmwareUpdateChannel(newUpdateChannel);
}
1 change: 1 addition & 0 deletions backend/firmwareupdateregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class FirmwareUpdateRegistry : public UpdateRegistry

private:
const QString updateChannel() const override;
void setUpdateChannel(const QString &newUpdateChannel) const override;
};

}
Expand Down
4 changes: 4 additions & 0 deletions backend/updateregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ void UpdateRegistry::fillFromJson(const QByteArray &text)
} catch(std::runtime_error &e) {
qCCritical(CATEGORY_UPDATES) << "Failed to parse update information:" << e.what();
}

if(!m_channels.contains(updateChannel())) {
setUpdateChannel(QStringLiteral("release"));
}
}

const QStringList UpdateRegistry::channelNames() const
Expand Down
1 change: 1 addition & 0 deletions backend/updateregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public slots:

private:
virtual const QString updateChannel() const = 0;
virtual void setUpdateChannel(const QString &newUpdateChannel) const = 0;
void setState(State newState);

QString m_directoryUrl;
Expand Down

0 comments on commit f113ef9

Please sign in to comment.