Fix logic a bit - avoid dereferencing NULL pointer

Closes https://github.com/mate-desktop/mate-panel/pull/257