fix bug in ui_state

after selecting a result item, the current query is reset
to 0 and the empty query is run against the db to get the
default results. i was forgetting to free the db_query
before preparing a new one.