mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-03 05:34:07 +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; }
|
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;
|
FormClosing -= FormSettings_FormClosing;
|
||||||
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK){
|
if (dialog.ShowDialog() == DialogResult.OK){
|
||||||
browser.ResumeNotification();
|
if (!dialog.IsRestarting){
|
||||||
|
browser.ResumeNotification();
|
||||||
|
|
||||||
BrowserProcessHandler.UpdatePrefs();
|
BrowserProcessHandler.UpdatePrefs();
|
||||||
ShouldReloadBrowser = dialog.ShouldReloadBrowser;
|
ShouldReloadBrowser = dialog.ShouldReloadBrowser;
|
||||||
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -21,7 +21,8 @@ private ProfileManager.Items SelectedItems{
|
|||||||
cbPluginData.Checked = value.HasFlag(ProfileManager.Items.PluginData);
|
cbPluginData.Checked = value.HasFlag(ProfileManager.Items.PluginData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsRestarting { get; private set; }
|
||||||
public bool ShouldReloadBrowser { get; private set; }
|
public bool ShouldReloadBrowser { get; private set; }
|
||||||
|
|
||||||
private readonly PluginManager plugins;
|
private readonly PluginManager plugins;
|
||||||
@ -131,10 +132,10 @@ private void btnContinue_Click(object sender, EventArgs e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
||||||
Program.Restart(Arguments.ArgDeleteCookies);
|
RestartProgram(Arguments.ArgDeleteCookies);
|
||||||
}
|
}
|
||||||
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
||||||
Program.Restart();
|
RestartProgram();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ShouldReloadBrowser = true;
|
ShouldReloadBrowser = true;
|
||||||
@ -152,10 +153,10 @@ private void btnContinue_Click(object sender, EventArgs e){
|
|||||||
|
|
||||||
if (importManager.IsRestarting){
|
if (importManager.IsRestarting){
|
||||||
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
||||||
Program.Restart(Arguments.ArgImportCookies);
|
RestartProgram(Arguments.ArgImportCookies);
|
||||||
}
|
}
|
||||||
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
||||||
Program.Restart();
|
RestartProgram();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -210,13 +211,18 @@ private void btnCancel_Click(object sender, EventArgs e){
|
|||||||
private void SetFlag(ProfileManager.Items flag, bool enable){
|
private void SetFlag(ProfileManager.Items flag, bool enable){
|
||||||
_selectedItems = enable ? _selectedItems | flag : _selectedItems & ~flag;
|
_selectedItems = enable ? _selectedItems | flag : _selectedItems & ~flag;
|
||||||
btnContinue.Enabled = _selectedItems != ProfileManager.Items.None;
|
btnContinue.Enabled = _selectedItems != ProfileManager.Items.None;
|
||||||
|
|
||||||
if (currentState == State.Import){
|
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){
|
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