mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
NetworkSettings: Don't assert when there are no network adapters
NetworkSettings normally filters out `loop` when populating its list of adapters. However, when checking if there aren't any adapters it did not take this into account. This causes it to crash later when trying to set the selected index of an empty combo box. This moves the check for no adapters to after filtering the list, so that shows the error message and exits.
This commit is contained in:
parent
dcb2f3aa89
commit
fedd087546
1 changed files with 6 additions and 6 deletions
|
@ -77,12 +77,6 @@ ErrorOr<void> NetworkSettingsWidget::setup()
|
|||
JsonParser parser(data);
|
||||
JsonValue proc_net_adapters_json = TRY(parser.parse());
|
||||
|
||||
// FIXME: This should be done before creating a window.
|
||||
if (proc_net_adapters_json.as_array().is_empty()) {
|
||||
GUI::MessageBox::show_error(window(), "No network adapters found!"sv);
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
size_t selected_adapter_index = 0;
|
||||
size_t index = 0;
|
||||
proc_net_adapters_json.as_array().for_each([&](auto& value) {
|
||||
|
@ -109,6 +103,12 @@ ErrorOr<void> NetworkSettingsWidget::setup()
|
|||
index++;
|
||||
});
|
||||
|
||||
// FIXME: This should be done before creating a window.
|
||||
if (m_adapter_names.is_empty()) {
|
||||
GUI::MessageBox::show_error(window(), "No network adapters found!"sv);
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
m_adapters_combobox->set_model(TRY(GUI::ItemListModel<DeprecatedString>::try_create(m_adapter_names)));
|
||||
m_adapters_combobox->on_change = [this](DeprecatedString const& text, GUI::ModelIndex const&) {
|
||||
on_switch_adapter(text);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue