From e6d4f5711f3063f961e78963ba0bd8fd3d3b4f72 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 27 Oct 2019 21:13:52 +0100 Subject: Fixing a bug that did not take settings into account when enabling controls on first configuration run (because ShowDialog distrupts main form event loop) --- spedytor/Form1.Designer.cs | 2 +- spedytor/Form1.cs | 18 ++++++++++++++---- spedytor/MysqlSettings.cs | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/spedytor/Form1.Designer.cs b/spedytor/Form1.Designer.cs index d504306..32913cc 100644 --- a/spedytor/Form1.Designer.cs +++ b/spedytor/Form1.Designer.cs @@ -255,7 +255,7 @@ this.Name = "Form1"; this.Text = "Spedytor"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); - this.Load += new System.EventHandler(this.Form1_Load); + this.Shown += new System.EventHandler(this.Form1_Shown); this.Resize += new System.EventHandler(this.Form1_Resize); ((System.ComponentModel.ISupportInitialize)(this.nInterval)).EndInit(); this.contextMenuStrip.ResumeLayout(false); diff --git a/spedytor/Form1.cs b/spedytor/Form1.cs index ce82b80..4448d8e 100644 --- a/spedytor/Form1.cs +++ b/spedytor/Form1.cs @@ -44,10 +44,17 @@ namespace spedytor this.Dispose(); } - private void Form1_Load(object sender, EventArgs e) + private void Form1_Shown(object sender, EventArgs e) { - if (!MySQL.getConfigured()) (new MysqlSettings()).ShowDialog(); - if (!MySQL.getConfigured()) this.Dispose(); + if (!MySQL.getConfigured()) + { + (new MysqlSettings()).ShowDialog(); + } + if (!MySQL.getConfigured()) + { + this.Dispose(); + return; + } this.restoreSettings(); this.refreshDatabaseList(); this.checkS3Options(); @@ -387,7 +394,10 @@ namespace spedytor private void restoreSettings() { - this.setSelectedDBs(Properties.OptionSettings.Default.DB_NAMES.Cast().ToList()); + if (Properties.OptionSettings.Default.DB_NAMES != null) + { + this.setSelectedDBs(Properties.OptionSettings.Default.DB_NAMES.Cast().ToList()); + } this.cSend.Checked = Properties.OptionSettings.Default.SEND_FLAG; this.nInterval.Value = Properties.OptionSettings.Default.RUN_INTERVAL; } diff --git a/spedytor/MysqlSettings.cs b/spedytor/MysqlSettings.cs index bce4f01..af7c636 100644 --- a/spedytor/MysqlSettings.cs +++ b/spedytor/MysqlSettings.cs @@ -63,7 +63,7 @@ namespace spedytor { Properties.Settings.Default.CONFIGURED = true; Properties.Settings.Default.Save(); - Close(); + Dispose(); } else { -- cgit v1.2.3