From 519b367108bf918b38333ccbb06c98c4e6871f7e Mon Sep 17 00:00:00 2001
From: Oliver Bock <oliver.bock@aei.mpg.de>
Date: Thu, 3 Apr 2008 17:15:34 +0200
Subject: [PATCH] Assert that there's at least one observer (changing vom DEBUG
 to NDEBUG due to use of assert() which is scrapped by the precompiler ifdef
 NDEBUG)

---
 Makefile          | 4 ++--
 WindowManager.cpp | 3 +++
 WindowManager.h   | 1 +
 main.C            | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index b0c47a7..669b32a 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ LIBS = -L${BOINC_PREFIX}/lib -Bstatic $(shell sdl-config --static-libs) -lfreety
 CPPFLAGS = -I/usr/include $(shell sdl-config --cflags) $(shell pkg-config --cflags ftgl)
 DEPS = Makefile
 OBJS = starlist.o snr_list.o pulsar_list.o AbstractGraphicsEngine.o Starsphere.o WindowManager.o ${RESOURCESPEC}.o Resource.o ResourceFactory.o
-DEBUGFLAGSCPP = -DDEBUG -pg -ggdb -O0
+DEBUGFLAGSCPP = -pg -ggdb -O0
 RESOURCESPEC = resources
 
 # primary role based tagets
@@ -22,7 +22,7 @@ release: clean starsphere
 debug: CPPFLAGS += $(DEBUGFLAGSCPP)
 memcheck: CPPFLAGS += $(DEBUGFLAGSCPP) -DDEBUG_VALGRIND
 callgrind: CPPFLAGS += $(DEBUGFLAGSCPP) -DDEBUG_VALGRIND
-release: CPPFLAGS += -O3 -Wall -Wno-switch-enum
+release: CPPFLAGS += -DNDEBUG -O3 -Wall -Wno-switch-enum
 release: LDFLAGS += -s
 
 # file based targets
diff --git a/WindowManager.cpp b/WindowManager.cpp
index 2f0bac5..b1a2496 100644
--- a/WindowManager.cpp
+++ b/WindowManager.cpp
@@ -96,6 +96,9 @@ bool WindowManager::initialize()
 
 void WindowManager::eventLoop()
 {
+	// be sure there's at least one observer!
+	assert(eventObservers.size() > 0);
+	
 	SDL_AddTimer(40, &timerCallbackRenderEvent, NULL);
 	SDL_AddTimer(1000, &timerCallbackBOINCUpdateEvent, NULL);
 
diff --git a/WindowManager.h b/WindowManager.h
index 37266bc..9b6d2b0 100644
--- a/WindowManager.h
+++ b/WindowManager.h
@@ -4,6 +4,7 @@
 #include <iostream>
 #include <string>
 #include <list>
+#include <cassert>
 
 #include <SDL.h>
 
diff --git a/main.C b/main.C
index 40500ed..e8d8d52 100644
--- a/main.C
+++ b/main.C
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
 	graphics.initialize(window.windowWidth(), window.windowHeight(), fontResource);
 	graphics.render(0);
 	
-#ifndef DEBUG
+#ifdef NDEBUG
 	window.toggleFullscreen();
 #endif
 	
-- 
GitLab