Преглед на файлове

Fix crashes on app shutdown

Ivan Savenko преди 7 месеца
родител
ревизия
8204990fa6
променени са 5 файла, в които са добавени 7 реда и са изтрити 33 реда
  1. 0 1
      client/media/CMusicHandler.cpp
  2. 0 3
      client/render/IScreenHandler.h
  3. 1 1
      client/renderSDL/ScreenHandler.cpp
  4. 1 3
      client/renderSDL/ScreenHandler.h
  5. 5 25
      clientapp/EntryPoint.cpp

+ 0 - 1
client/media/CMusicHandler.cpp

@@ -91,7 +91,6 @@ CMusicHandler::~CMusicHandler()
 		std::scoped_lock guard(mutex);
 
 		Mix_HookMusicFinished(nullptr);
-		current->stop();
 
 		current.reset();
 		next.reset();

+ 0 - 3
client/render/IScreenHandler.h

@@ -25,9 +25,6 @@ public:
 	/// Updates window state after fullscreen state has been changed in settings
 	virtual void onScreenResize() = 0;
 
-	/// De-initializes window state
-	virtual void close() = 0;
-
 	/// Fills screen with black color, erasing any existing content
 	virtual void clearScreen() = 0;
 

+ 1 - 1
client/renderSDL/ScreenHandler.cpp

@@ -595,7 +595,7 @@ void ScreenHandler::destroyWindow()
 	}
 }
 
-void ScreenHandler::close()
+ScreenHandler::~ScreenHandler()
 {
 	if(settings["general"]["notifications"].Bool())
 		NotificationHandler::destroy();

+ 1 - 3
client/renderSDL/ScreenHandler.h

@@ -96,13 +96,11 @@ public:
 
 	/// Creates and initializes screen, window and SDL state
 	ScreenHandler();
+	~ScreenHandler();
 
 	/// Updates and potentially recreates target screen to match selected fullscreen status
 	void onScreenResize() final;
 
-	/// De-initializes and destroys screen, window and SDL state
-	void close() final;
-
 	/// Fills screen with black color, erasing any existing content
 	void clearScreen() final;
 

+ 5 - 25
clientapp/EntryPoint.cpp

@@ -62,8 +62,6 @@ namespace po_style = boost::program_options::command_line_style;
 static std::atomic<bool> headlessQuit = false;
 static std::optional<std::string> criticalInitializationError;
 
-[[noreturn]] static void quitApplication();
-
 static void init()
 {
 	try
@@ -397,14 +395,9 @@ int main(int argc, char * argv[])
 	}
 	catch (const GameShutdownException & )
 	{
-		quitApplication();
+		// no-op - just break out of main loop
 	}
 
-	return 0;
-}
-
-[[noreturn]] static void quitApplication()
-{
 	GAME->server().endNetwork();
 
 	if(!settings["session"]["headless"].Bool())
@@ -420,29 +413,16 @@ int main(int argc, char * argv[])
 	if(!settings["session"]["headless"].Bool())
 	{
 		CMessage::dispose();
-
 		vstd::clear_pointer(graphics);
 	}
 
-	vstd::clear_pointer(LIBRARY);
+	ENGINE.reset();
 
-	// sometimes leads to a hang. TODO: investigate
-	//vstd::clear_pointer(console);// should be removed after everything else since used by logging
-
-	if(!settings["session"]["headless"].Bool())
-		ENGINE->screenHandler().close();
-
-	//if(logConfig != nullptr)
-	//{
-	//	logConfig->deconfigure();
-	//	delete logConfig;
-	//	logConfig = nullptr;
-	//}
-
-	//ENGINE.reset();
+	vstd::clear_pointer(LIBRARY);
+	logConfigurator.deconfigure();
 
 	std::cout << "Ending...\n";
-	::exit(0);
+	return 0;
 }
 
 /// Notify user about encountered fatal error and terminate the game