mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-23 21:15:49 +02:00
Fix a crash when restarting after importing/resetting profile & refactor
This commit is contained in:
parent
d5ad1d0daa
commit
a44cb884c4
Core
@ -210,4 +210,10 @@ private sealed class PathInfo{
|
||||
public string Relative { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
static class ProfileManagerExtensions{
|
||||
public static bool NeedsRestart(this ProfileManager.Items items){
|
||||
return items.HasFlag(ProfileManager.Items.SystemConfig) || items.HasFlag(ProfileManager.Items.Session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,10 +67,13 @@ private void btnManageOptions_Click(object sender, EventArgs e){
|
||||
FormClosing -= FormSettings_FormClosing;
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
browser.ResumeNotification();
|
||||
if (!dialog.IsRestarting){
|
||||
browser.ResumeNotification();
|
||||
|
||||
BrowserProcessHandler.UpdatePrefs();
|
||||
ShouldReloadBrowser = dialog.ShouldReloadBrowser;
|
||||
BrowserProcessHandler.UpdatePrefs();
|
||||
ShouldReloadBrowser = dialog.ShouldReloadBrowser;
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
else{
|
||||
|
@ -21,7 +21,8 @@ private ProfileManager.Items SelectedItems{
|
||||
cbPluginData.Checked = value.HasFlag(ProfileManager.Items.PluginData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsRestarting { get; private set; }
|
||||
public bool ShouldReloadBrowser { get; private set; }
|
||||
|
||||
private readonly PluginManager plugins;
|
||||
@ -131,10 +132,10 @@ private void btnContinue_Click(object sender, EventArgs e){
|
||||
}
|
||||
|
||||
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
||||
Program.Restart(Arguments.ArgDeleteCookies);
|
||||
RestartProgram(Arguments.ArgDeleteCookies);
|
||||
}
|
||||
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
||||
Program.Restart();
|
||||
RestartProgram();
|
||||
}
|
||||
else{
|
||||
ShouldReloadBrowser = true;
|
||||
@ -152,10 +153,10 @@ private void btnContinue_Click(object sender, EventArgs e){
|
||||
|
||||
if (importManager.IsRestarting){
|
||||
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
||||
Program.Restart(Arguments.ArgImportCookies);
|
||||
RestartProgram(Arguments.ArgImportCookies);
|
||||
}
|
||||
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
||||
Program.Restart();
|
||||
RestartProgram();
|
||||
}
|
||||
}
|
||||
else{
|
||||
@ -210,13 +211,18 @@ private void btnCancel_Click(object sender, EventArgs e){
|
||||
private void SetFlag(ProfileManager.Items flag, bool enable){
|
||||
_selectedItems = enable ? _selectedItems | flag : _selectedItems & ~flag;
|
||||
btnContinue.Enabled = _selectedItems != ProfileManager.Items.None;
|
||||
|
||||
|
||||
if (currentState == State.Import){
|
||||
btnContinue.Text = _selectedItems.HasFlag(ProfileManager.Items.Session) ? "Import && Restart" : "Import Profile";
|
||||
btnContinue.Text = _selectedItems.NeedsRestart() ? "Import && Restart" : "Import Profile";
|
||||
}
|
||||
else if (currentState == State.Reset){
|
||||
btnContinue.Text = _selectedItems.HasFlag(ProfileManager.Items.Session) ? "Restore && Restart" : "Restore Defaults";
|
||||
btnContinue.Text = _selectedItems.NeedsRestart() ? "Restore && Restart" : "Restore Defaults";
|
||||
}
|
||||
}
|
||||
|
||||
private void RestartProgram(params string[] extraArgs){
|
||||
IsRestarting = true;
|
||||
Program.Restart(extraArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user