Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion desktop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn start() {

match exit_reason {
app::ExitReason::Restart | app::ExitReason::UiAccelerationFailure => {
tracing::error!("Restarting application");
tracing::info!("Restarting application");
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
#[cfg(target_family = "unix")]
let _ = std::os::unix::process::CommandExt::exec(&mut command);
Expand Down
4 changes: 3 additions & 1 deletion editor/src/messages/dialog/dialog_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ pub enum DialogMessage {
},
RequestNewDocumentDialog,
RequestPreferencesDialog,
RequestConfirmRestartDialog,
RequestConfirmRestartDialog {
preferences_requiring_restart: Vec<String>,
},
}
6 changes: 2 additions & 4 deletions editor/src/messages/dialog/dialog_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,9 @@ impl MessageHandler<DialogMessage, DialogMessageContext<'_>> for DialogMessageHa
self.on_dismiss = Some(PreferencesDialogMessage::Confirm.into());
self.preferences_dialog.send_dialog_to_frontend(responses, preferences);
}
DialogMessage::RequestConfirmRestartDialog => {
DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart } => {
self.on_dismiss = Some(DialogMessage::Close.into());
let dialog = ConfirmRestartDialog {
changed_settings: vec!["Disable UI Acceleration".into()],
};
let dialog = ConfirmRestartDialog { preferences_requiring_restart };
dialog.send_dialog_to_frontend(responses);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ impl MessageHandler<PreferencesDialogMessage, PreferencesDialogMessageContext<'_
}
PreferencesDialogMessage::Confirm => {
if let Some(unmodified_preferences) = &self.unmodified_preferences
&& unmodified_preferences.needs_restart(preferences)
&& let preferences_requiring_restart = unmodified_preferences.preferences_requiring_restart(preferences)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This restart-setting list is computed from a stale baseline because unmodified_preferences is never reset when the Preferences dialog is reopened. After a previous visit captured a snapshot, later confirmations can show the wrong settings as requiring restart.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs, line 31:

<comment>This restart-setting list is computed from a stale baseline because `unmodified_preferences` is never reset when the Preferences dialog is reopened. After a previous visit captured a snapshot, later confirmations can show the wrong settings as requiring restart.</comment>

<file context>
@@ -28,9 +28,10 @@ impl MessageHandler<PreferencesDialogMessage, PreferencesDialogMessageContext<'_
 			PreferencesDialogMessage::Confirm => {
 				if let Some(unmodified_preferences) = &self.unmodified_preferences
-					&& unmodified_preferences.needs_restart(preferences)
+					&& let preferences_requiring_restart = unmodified_preferences.preferences_requiring_restart(preferences)
+					&& !preferences_requiring_restart.is_empty()
 				{
</file context>

&& !preferences_requiring_restart.is_empty()
{
responses.add(DialogMessage::RequestConfirmRestartDialog);
responses.add(DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart });
} else {
responses.add(DialogMessage::Close);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::messages::prelude::*;

/// A dialog for confirming the restart of the application when changing a preference that requires a restart to take effect.
pub struct ConfirmRestartDialog {
pub changed_settings: Vec<String>,
pub preferences_requiring_restart: Vec<String>,
}

impl DialogLayoutHolder for ConfirmRestartDialog {
Expand All @@ -30,7 +30,7 @@ impl DialogLayoutHolder for ConfirmRestartDialog {

impl LayoutHolder for ConfirmRestartDialog {
fn layout(&self) -> Layout {
let changed_settings = "• ".to_string() + &self.changed_settings.join("\n• ");
let changed_settings = "• ".to_string() + &self.preferences_requiring_restart.join("\n• ");

Layout(vec![
LayoutGroup::row(vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()]),
Expand Down
18 changes: 10 additions & 8 deletions editor/src/messages/preferences/preferences_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ pub struct PreferencesMessageHandler {
}

impl PreferencesMessageHandler {
#[cfg(not(target_os = "macos"))]
pub fn needs_restart(&self, other: &Self) -> bool {
self.disable_ui_acceleration != other.disable_ui_acceleration
}

#[cfg(target_os = "macos")]
pub fn needs_restart(&self, other: &Self) -> bool {
self.disable_ui_acceleration != other.disable_ui_acceleration || self.vsync != other.vsync
pub fn preferences_requiring_restart(&self, other: &Self) -> Vec<String> {
let mut requiring_restart = Vec::new();
if self.disable_ui_acceleration != other.disable_ui_acceleration {
requiring_restart.push("Disable UI Acceleration");
}
#[cfg(target_os = "macos")]
if self.vsync != other.vsync {
requiring_restart.push("Enable V-Sync");
}
requiring_restart.into_iter().map(String::from).collect()
Comment on lines +32 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This implementation can be made more direct by creating a Vec<String> from the beginning and pushing allocated strings, avoiding the final conversion step. This is slightly more efficient and arguably clearer.

Suggested change
let mut requiring_restart = Vec::new();
if self.disable_ui_acceleration != other.disable_ui_acceleration {
requiring_restart.push("Disable UI Acceleration");
}
#[cfg(target_os = "macos")]
if self.vsync != other.vsync {
requiring_restart.push("Enable V-Sync");
}
requiring_restart.into_iter().map(String::from).collect()
let mut requiring_restart = Vec::new();
if self.disable_ui_acceleration != other.disable_ui_acceleration {
requiring_restart.push("Disable UI Acceleration".to_string());
}
#[cfg(target_os = "macos")]
if self.vsync != other.vsync {
requiring_restart.push("Enable V-Sync".to_string());
}
requiring_restart

}

pub fn get_selection_mode(&self) -> SelectionMode {
Expand Down
Loading