Skip to content
Permalink
Browse files
Fixed infinite loop
Turns out the seemingly random crashes we were having were actually being caused by an infinite while loop that was created when the user tried to send a message whilst the entry box was blank as it just kept on checking for a message without letting the user alter anything. The function now just quits early when the message is blank
  • Loading branch information
hortonr6 committed Nov 15, 2017
1 parent e3e1f4b commit a2a4db3e3d2e08d293224d6917d3318f96b6c28c
Showing 1 changed file with 3 additions and 3 deletions.
@@ -50,9 +50,9 @@ def sendMessage(event=None):
interface and then takes this input from the user and feeds it to the
chatbot/server, allowing it to respond to the input appropriately.'''

sMessage = ""
while sMessage is None or sMessage == "": #loops through until user actually says something
sMessage = userInput.get() #input from user, needs to come from interface
sMessage = userInput.get()
if sMessage is None or sMessage == "": #Checks if the user has actually entered anything before sending
return None #Ends the function before any message is sent to prevent sending of blank message

thisSocket.send(sMessage.encode())
chatHistory.configure(state="normal")

0 comments on commit a2a4db3

Please sign in to comment.