mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 06:02:11 +00:00
Fixed deadlock caused by errors displayed by texture loading
This commit is contained in:
parent
78fe6c306e
commit
bd811aac7d
2 changed files with 88 additions and 69 deletions
|
@ -46,11 +46,11 @@ namespace CodeImp.DoomBuilder
|
|||
private static string storedtext = string.Empty;
|
||||
private static DebugConsole me;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
#region ================== Properties
|
||||
|
||||
public bool AlwaysOnTop { get { return alwaysontop.Checked; } }
|
||||
public bool AlwaysOnTop { get { return alwaysontop.Checked; } }
|
||||
public static int Counter { get { return counter; } }
|
||||
|
||||
#endregion
|
||||
|
@ -106,32 +106,28 @@ namespace CodeImp.DoomBuilder
|
|||
public static void Write(DebugMessageType type, string text) { Write(type, text, true); }
|
||||
public static void Write(DebugMessageType type, string text, bool append)
|
||||
{
|
||||
if(me != null && me.InvokeRequired)
|
||||
{
|
||||
me.Invoke(new Action<DebugMessageType, string, bool>(Write), new object[] { type, text, append });
|
||||
}
|
||||
else
|
||||
{
|
||||
if(messages.Count + 1 > MAX_MESSAGES) lock (messages) { messages.RemoveAt(0); }
|
||||
messages.Add(new KeyValuePair<DebugMessageType, string>(type, text));
|
||||
if(me != null && (me.filters & type) == type)
|
||||
{
|
||||
me.AddMessage(type, text, true, append);
|
||||
}
|
||||
}
|
||||
if (General.MainWindow == null)
|
||||
return;
|
||||
General.MainWindow.RunOnUIThread(() =>
|
||||
{
|
||||
if (messages.Count + 1 > MAX_MESSAGES) lock (messages) { messages.RemoveAt(0); }
|
||||
messages.Add(new KeyValuePair<DebugMessageType, string>(type, text));
|
||||
if (me != null && (me.filters & type) == type)
|
||||
{
|
||||
me.AddMessage(type, text, true, append);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
if(me != null && me.InvokeRequired)
|
||||
{
|
||||
me.Invoke(new Action(Clear));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(me != null) me.console.Clear();
|
||||
messages.Clear();
|
||||
}
|
||||
if (General.MainWindow == null)
|
||||
return;
|
||||
General.MainWindow.RunOnUIThread(() =>
|
||||
{
|
||||
if (me != null) me.console.Clear();
|
||||
messages.Clear();
|
||||
});
|
||||
}
|
||||
|
||||
public static void StartTimer()
|
||||
|
|
|
@ -282,6 +282,11 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//mxd. Hints
|
||||
hintsPanel = new HintsPanel();
|
||||
hintsDocker = new Docker("hints", "Help", hintsPanel);
|
||||
|
||||
// [ZZ]
|
||||
InvokeTimer.Tick += new EventHandler(InvokeHandler);
|
||||
InvokeTimer.Interval = 10;
|
||||
InvokeTimer.Start();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -4112,12 +4117,37 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
#region ================== Threadsafe updates
|
||||
|
||||
Timer InvokeTimer = new Timer();
|
||||
List<System.Action> InvokeActions = new List<System.Action>();
|
||||
|
||||
// this is actually InvokeTimer.Tick handler
|
||||
void InvokeHandler(object sender, EventArgs e)
|
||||
{
|
||||
InvokeTimer.Stop();
|
||||
|
||||
List<System.Action> actions = null;
|
||||
lock (InvokeActions)
|
||||
{
|
||||
if (InvokeActions.Count > 0)
|
||||
{
|
||||
actions = new List<System.Action>();
|
||||
actions.AddRange(InvokeActions);
|
||||
}
|
||||
}
|
||||
|
||||
if (actions == null)
|
||||
return;
|
||||
|
||||
foreach (System.Action action in actions)
|
||||
action();
|
||||
|
||||
InvokeTimer.Start();
|
||||
}
|
||||
|
||||
public void RunOnUIThread(System.Action action)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
Invoke(action);
|
||||
else
|
||||
action();
|
||||
if (!InvokeRequired) action();
|
||||
else lock (InvokeActions) InvokeActions.Add(action);
|
||||
}
|
||||
|
||||
public void UpdateStatus()
|
||||
|
@ -4198,28 +4228,24 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private delegate void SetWarningsCountCallback(int count, bool blink);
|
||||
internal void SetWarningsCount(int count, bool blink)
|
||||
{
|
||||
if(this.InvokeRequired)
|
||||
{
|
||||
SetWarningsCountCallback d = SetWarningsCount;
|
||||
this.Invoke(d, new object[] { count, blink });
|
||||
return;
|
||||
}
|
||||
RunOnUIThread(() =>
|
||||
{
|
||||
// Update icon, start annoying blinking if necessary
|
||||
if (count > 0)
|
||||
{
|
||||
if (blink && !blinkTimer.Enabled) blinkTimer.Start();
|
||||
warnsLabel.Image = Resources.Warning;
|
||||
}
|
||||
else
|
||||
{
|
||||
blinkTimer.Stop();
|
||||
warnsLabel.Image = Resources.WarningOff;
|
||||
warnsLabel.BackColor = SystemColors.Control;
|
||||
}
|
||||
|
||||
// Update icon, start annoying blinking if necessary
|
||||
if(count > 0)
|
||||
{
|
||||
if(blink && !blinkTimer.Enabled) blinkTimer.Start();
|
||||
warnsLabel.Image = Resources.Warning;
|
||||
}
|
||||
else
|
||||
{
|
||||
blinkTimer.Stop();
|
||||
warnsLabel.Image = Resources.WarningOff;
|
||||
warnsLabel.BackColor = SystemColors.Control;
|
||||
}
|
||||
|
||||
// Update errors count
|
||||
warnsLabel.Text = count.ToString();
|
||||
// Update errors count
|
||||
warnsLabel.Text = count.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
//mxd. Bliks warnings indicator
|
||||
|
@ -4240,7 +4266,10 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
if(!blinkTimer.Enabled) return;
|
||||
try
|
||||
{
|
||||
this.Invoke(new CallBlink(Blink));
|
||||
RunOnUIThread(() =>
|
||||
{
|
||||
Blink();
|
||||
});
|
||||
} catch(ObjectDisposedException) { } //la-la-la. We don't care.
|
||||
}
|
||||
|
||||
|
@ -4465,24 +4494,18 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
#region ================== Updater (mxd)
|
||||
|
||||
private delegate void UpdateAvailableCallback(int remoterev, string changelog);
|
||||
internal void UpdateAvailable(int remoterev, string changelog)
|
||||
{
|
||||
if(this.InvokeRequired)
|
||||
{
|
||||
UpdateAvailableCallback d = UpdateAvailable;
|
||||
this.Invoke(d, new object[] { remoterev, changelog });
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show the window
|
||||
UpdateForm form = new UpdateForm(remoterev, changelog);
|
||||
form.FormClosing += delegate
|
||||
{
|
||||
// Update ignored revision number
|
||||
General.Settings.IgnoredRemoteRevision = (form.IgnoreThisUpdate ? remoterev : 0);
|
||||
};
|
||||
form.Show(this);
|
||||
}
|
||||
internal void UpdateAvailable(int remoterev, string changelog)
|
||||
{
|
||||
RunOnUIThread(() => {
|
||||
// Show the window
|
||||
UpdateForm form = new UpdateForm(remoterev, changelog);
|
||||
form.FormClosing += delegate
|
||||
{
|
||||
// Update ignored revision number
|
||||
General.Settings.IgnoredRemoteRevision = (form.IgnoreThisUpdate ? remoterev : 0);
|
||||
};
|
||||
form.Show(this);
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue