From 617090cfdaf6acfdef7f2de6cd521559d07d311e Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Mon, 6 Jan 2014 18:20:42 +0100
Subject: [PATCH] event/IdleMonitor: cancel in destructor only if active

Debug-mode workaround for bogus assertion failure.
---
 src/event/IdleMonitor.hxx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/event/IdleMonitor.hxx b/src/event/IdleMonitor.hxx
index 8d3928583..dac7ab5b0 100644
--- a/src/event/IdleMonitor.hxx
+++ b/src/event/IdleMonitor.hxx
@@ -45,7 +45,12 @@ public:
 		:loop(_loop), active(false) {}
 
 	~IdleMonitor() {
-		Cancel();
+#ifndef NDEBUG
+		/* this check is redundant, it is only here to avoid
+		   the assertion in Cancel() */
+		if (IsActive())
+#endif
+			Cancel();
 	}
 
 	EventLoop &GetEventLoop() const {