apprt: switch to reload_config action that calls update_config API

This commit is contained in:
Mitchell Hashimoto
2024-11-22 10:43:51 -08:00
parent 6371af0d8e
commit a191f3c396
6 changed files with 132 additions and 59 deletions

View File

@@ -1065,8 +1065,8 @@ fn updateRendererHealth(self: *Surface, health: renderer.Health) void {
fn notifyConfigConditionalState(self: *Surface) void {
self.rt_app.performAction(
.{ .surface = self },
.config_change_conditional_state,
{},
.reload_config,
.{ .soft = true },
) catch |err| {
log.warn("failed to notify app of config state change err={}", .{err});
};
@@ -1077,8 +1077,22 @@ fn notifyConfigConditionalState(self: *Surface) void {
/// or other surfaces.
pub fn updateConfig(
self: *Surface,
config: *const configpkg.Config,
original: *const configpkg.Config,
) !void {
// Apply our conditional state. If we fail to apply the conditional state
// then we log and attempt to move forward with the old config.
var config_: ?configpkg.Config = original.changeConditionalState(
self.config_conditional_state,
) catch |err| err: {
log.warn("failed to apply conditional state to config err={}", .{err});
break :err null;
};
defer if (config_) |*c| c.deinit();
// We want a config pointer for everything so we get that either
// based on our conditional state or the original config.
const config: *const configpkg.Config = if (config_) |*c| c else original;
// Update our new derived config immediately
const derived = DerivedConfig.init(self.alloc, config) catch |err| {
// If the derivation fails then we just log and return. We don't