seamus

commit 8be0d91601a26d687bd62472b92ef1155c37bc72

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

queue: if recv_entity returned NULL, don't attempt to keep fetching

Apparently, when mpd_recv_entity has either stump on an error or has
reached the end of the entity list, it'll yield NULL, so we don't keep
fetching data from it.

 src/queue.c | 12 ++++++------
 src/ui.c | 2 +-


diff --git a/src/queue.c b/src/queue.c
index 6c12dc210676944e961ce8a1dd86344200221331..69b3e07f6462586cd5595d416eebb20ebc7e4538 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -19,13 +19,11 @@
 		for (index = 0; index < max_count; index++) {
 			entity = mpd_recv_entity(seamus->conn);
 			if (entity == NULL) {
-				if (mpd_connection_get_error(seamus->conn) != MPD_ERROR_SUCCESS) {
-					log_error("%s\n", mpd_connection_get_error_message(seamus->conn));
-
-					return 1;
-				}
+				// TODO: Discover if the queue have ended, or we
+				// have received an error here
+				break;
 
-				continue;
+				return 0;
 			} else {
 				enum mpd_entity_type type = mpd_entity_get_type(entity);
 
@@ -61,6 +59,8 @@ 		return 0;
 	} else {
 		const char *message = mpd_connection_get_error_message(seamus->conn);
 		log_error("MPD Error - Queue: %s", message);
+
+		mpd_response_finish(seamus->conn);
 
 		return 1;
 	}




diff --git a/src/ui.c b/src/ui.c
index e9614b9e19f4a2adec39258b3ccc3279168e637a..c3c03d388cfc7a6d1581e9bbf1f7b523c3947bef 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -148,7 +148,7 @@ 		tickit_renderbuffer_text(render_buffer, "Hello, welcome to seamus");
 		tickit_renderbuffer_restore(render_buffer);
 	}
 
-	int max_songs = tickit_window_lines(win) - 5;
+	int max_songs = tickit_window_lines(seamus->main_window);
 	log_debug("Max songs allowed: %d of total %d lines", max_songs, tickit_window_lines(win));
 
 	fetch_current_queue(seamus, max_songs);