fix segfault with xmpp query in layout

check that protocl is not NULL before calling methods on it, might
happen with loadable protocols