Cleaner buffer flush for QDebug message handler

closes #691