Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(display): retry reverting configuration only if device was added or removed #3539

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
typo
  • Loading branch information
FrogTheFrog committed Jan 15, 2025
commit fd2d4d393555216a0ce7d2f9916a8e474630d640
2 changes: 1 addition & 1 deletion src/display_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,13 @@

DD_DATA.sm_instance->schedule([try_once = (option == revert_option_e::try_once), tried_out_devices = std::set<std::string> {}](auto &settings_iface, auto &stop_token) mutable {
if (try_once) {
std::ignore = settings_iface.revertSettings();

Check warning on line 679 in src/display_device.cpp

View check run for this annotation

Codecov / codecov/patch

src/display_device.cpp#L679

Added line #L679 was not covered by tests
stop_token.requestStop();
return;

Check warning on line 681 in src/display_device.cpp

View check run for this annotation

Codecov / codecov/patch

src/display_device.cpp#L681

Added line #L681 was not covered by tests
}

auto available_devices { [&settings_iface]() {
const auto devices { settings_iface.enumAvailableDevices() };

Check warning on line 685 in src/display_device.cpp

View check run for this annotation

Codecov / codecov/patch

src/display_device.cpp#L684-L685

Added lines #L684 - L685 were not covered by tests
std::set<std::string> parsed_devices;

std::transform(
Expand All @@ -690,12 +690,12 @@
std::inserter(parsed_devices, std::end(parsed_devices)),
[](const auto &device) { return device.m_device_id + " - " + device.m_friendly_name; });

return parsed_devices;
}() };

Check warning on line 694 in src/display_device.cpp

View check run for this annotation

Codecov / codecov/patch

src/display_device.cpp#L693-L694

Added lines #L693 - L694 were not covered by tests
if (available_devices == tried_out_devices) {
BOOST_LOG(debug) << "Skipping reverting configuration, because the no newly added/removed devices were detected since last check. Currently available devices:\n"
BOOST_LOG(debug) << "Skipping reverting configuration, because no newly added/removed devices were detected since last check. Currently available devices:\n"
<< toJson(available_devices);
return;

Check warning on line 698 in src/display_device.cpp

View check run for this annotation

Codecov / codecov/patch

src/display_device.cpp#L698

Added line #L698 was not covered by tests
}

using enum SettingsManagerInterface::RevertResult;
Expand All @@ -711,7 +711,7 @@
// If we have failed to revert settings then we will try to do it next time only if a device was added/removed
BOOST_LOG(warning) << "Failed to revert display device configuration (will retry once devices are added or removed). Enabling all of the available devices:\n"
<< toJson(available_devices);
tried_out_devices.swap(available_devices);

Check warning on line 714 in src/display_device.cpp

View check run for this annotation

Codecov / codecov/patch

src/display_device.cpp#L714

Added line #L714 was not covered by tests
},
scheduler_option);
}
Expand Down
Loading