Browse Source

Fixed possible NullReferenceException points for asynchronous methods.

tags/3.0.3
Teknikode 4 years ago
parent
commit
0a6bcb2d82

+ 1
- 1
Combot/Bot.cs View File

@@ -505,7 +505,7 @@ namespace Combot
Regex whoRegex = new Regex(whoStyle);
IRC.Command.SendWho(newCommand.Nick.Nickname);
ServerReplyMessage whoReply = IRC.Message.GetServerReply(IRCReplyCode.RPL_WHOREPLY, whoStyle);
if (whoReply.ReplyCode != 0)
if (whoReply != null && whoReply.ReplyCode != 0)
{
Match whoMatch = whoRegex.Match(whoReply.Message);


+ 2
- 3
IRCServices/Messaging/Messages.cs View File

@@ -445,11 +445,12 @@ namespace Combot.IRCServices.Messaging
}
}

string rawMessage = message;
await Task.Run(() =>
{
if (RawMessageEvent != null)
{
RawMessageEvent(this, message);
RawMessageEvent(this, rawMessage);
}
});
}
@@ -462,7 +463,6 @@ namespace Combot.IRCServices.Messaging
reply.Match = match;
ServerReplyEvent += (sender, e) => HandleReply(sender, e, reply);
reply.Ready.Wait(TimeSpan.FromMilliseconds(5000));
ServerReplyEvent -= (obj, e) => HandleReply(obj, e, reply);
return reply.Result;
}

@@ -473,7 +473,6 @@ namespace Combot.IRCServices.Messaging
error.Match = match;
ServerReplyEvent += (sender, e) => HandleError(sender, e, error);
error.Ready.Wait(TimeSpan.FromMilliseconds(5000));
ServerReplyEvent -= (sender, e) => HandleError(sender, e, error);
return error.Result;
}


+ 6
- 4
Interface/ViewModels/MainViewModel.cs View File

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using System.Net;
using System.Runtime.Remoting.Channels;
using System.Threading;
using System.Windows;
using System.Windows.Documents;
using Combot;
using Combot.IRCServices.Messaging;
@@ -385,7 +386,7 @@ namespace Interface.ViewModels
}
if (LocationList.Contains(location))
{
App.Current.Dispatcher.Invoke((Action)(() => LocationList.Remove(location)));
Application.Current.Dispatcher.Invoke((Action)(() => LocationList.Remove(location)));
}
BufferLock.EnterWriteLock();
if (BufferList.Exists(buf => buf.Server == SelectedServer && buf.Location == location))
@@ -445,7 +446,7 @@ namespace Interface.ViewModels
BufferLock.ExitWriteLock();
if (SelectedServer == server && !LocationList.Contains(location))
{
App.Current.Dispatcher.Invoke((Action) (() => LocationList.Add(location)));
Application.Current.Dispatcher.Invoke((Action) (() => LocationList.Add(location)));
}
BufferLock.EnterWriteLock();
BufferInfo buffer = BufferList.Find(buf => buf.Server == server && buf.Location == location);
@@ -460,12 +461,13 @@ namespace Interface.ViewModels

private void ChangeServer()
{
App.Current.Dispatcher.Invoke((Action)(() => LocationList.Clear()));
Application.Current.Dispatcher.Invoke((Action)(() => LocationList.Clear()));
for (int i = 0; i < BufferList.Count; i++)
{
if (BufferList[i].Server == SelectedServer)
{
App.Current.Dispatcher.Invoke((Action)(() => LocationList.Add(BufferList[i].Location)));
int index = i;
Application.Current.Dispatcher.Invoke((Action)(() => LocationList.Add(BufferList[index].Location)));
}
}
if (LocationList.Any())

+ 6
- 3
Modules/Weather Information/Weather_Information.cs View File

@@ -43,14 +43,17 @@ namespace Combot.Modules.Plugins
XmlNodeList nodes2 = doc2.SelectNodes("/current_observation");

string location = "";
if (nodes2.Count > 0)
if (nodes2 != null && nodes2.Count > 0)
{
foreach (XmlNode node2 in nodes2)
{
XmlNodeList sub_node2 = doc2.SelectNodes("/current_observation/display_location");
foreach (XmlNode xn2 in sub_node2)
if (sub_node2 != null)
{
location = xn2["full"].InnerText;
foreach (XmlNode xn2 in sub_node2)
{
location = xn2["full"].InnerText;
}
}
}
}

Loading…
Cancel
Save