Impossible to exit infinite while loop #197
review changes for 18aca45673 (r26209938)
			
			
This commit is contained in:
		@@ -1069,13 +1069,8 @@ static void checkForceExit(lua_State *lua, lua_Debug *luadebug)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	tic_tick_data* tick = machine->data;
 | 
						tic_tick_data* tick = machine->data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(tick->hook)
 | 
						if(tick->forceExit && tick->forceExit(tick->data))
 | 
				
			||||||
	{
 | 
							luaL_error(lua, "script execution was interrupted");
 | 
				
			||||||
		tick->hook(tick->data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if(tick->forceExit)
 | 
					 | 
				
			||||||
			luaL_error(lua, "script execution was interrupted");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void initAPI(tic_machine* machine)
 | 
					static void initAPI(tic_machine* machine)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								src/run.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/run.c
									
									
									
									
									
								
							@@ -178,14 +178,11 @@ static void preseed()
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void poll(void* data)
 | 
					static bool forceExit(void* data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Run* run = (Run*)data;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while(pollEvent());
 | 
						while(pollEvent());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (getStudioMode() != TIC_RUN_MODE)
 | 
						return getStudioMode() != TIC_RUN_MODE;
 | 
				
			||||||
		run->tickData.forceExit = true;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void initRun(Run* run, Console* console, tic_mem* tic)
 | 
					void initRun(Run* run, Console* console, tic_mem* tic)
 | 
				
			||||||
@@ -207,8 +204,7 @@ void initRun(Run* run, Console* console, tic_mem* tic)
 | 
				
			|||||||
			.data = run,
 | 
								.data = run,
 | 
				
			||||||
			.exit = onExit,
 | 
								.exit = onExit,
 | 
				
			||||||
			.preprocessor = processDoFile,
 | 
								.preprocessor = processDoFile,
 | 
				
			||||||
			.hook = poll,
 | 
								.forceExit = forceExit,
 | 
				
			||||||
			.forceExit = false,
 | 
					 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,19 +45,18 @@ typedef struct
 | 
				
			|||||||
typedef void(*TraceOutput)(void*, const char*, u8 color);
 | 
					typedef void(*TraceOutput)(void*, const char*, u8 color);
 | 
				
			||||||
typedef void(*ErrorOutput)(void*, const char*);
 | 
					typedef void(*ErrorOutput)(void*, const char*);
 | 
				
			||||||
typedef void(*ExitCallback)(void*);
 | 
					typedef void(*ExitCallback)(void*);
 | 
				
			||||||
typedef void(*HookCallback)(void*);
 | 
					typedef bool(*CheckForceExit)(void*);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct
 | 
					typedef struct
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	TraceOutput trace;
 | 
						TraceOutput trace;
 | 
				
			||||||
	ErrorOutput error;
 | 
						ErrorOutput error;
 | 
				
			||||||
	ExitCallback exit;
 | 
						ExitCallback exit;
 | 
				
			||||||
	HookCallback hook;
 | 
						CheckForceExit forceExit;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	u64 (*counter)();
 | 
						u64 (*counter)();
 | 
				
			||||||
	u64 (*freq)();
 | 
						u64 (*freq)();
 | 
				
			||||||
	u64 start;
 | 
						u64 start;
 | 
				
			||||||
	bool forceExit;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void (*preprocessor)(void* data, char* dst);
 | 
						void (*preprocessor)(void* data, char* dst);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user