Fix crash when instantiating multiple QApplications on QWS
Fix crash when instantiating multiple QApplications on QWS

Copy variable initialization/cleanup code from X11

Reviewed-by: Tom

pruiz/wkhtmltopdf-qt,radekp/qt,radekp/qt,radekp/qt,radekp/qt,pruiz/wkhtmltopdf-qt,igor-sfdc/qt-wk,pruiz/wkhtmltopdf-qt,radekp/qt,pruiz/wkhtmltopdf-qt,igor-sfdc/qt-wk,igor-sfdc/qt-wk,igor-sfdc/qt-wk,pruiz/wkhtmltopdf-qt,igor-sfdc/qt-wk,pruiz/wkhtmltopdf-qt,igor-sfdc/qt-wk,pruiz/wkhtmltopdf-qt,radekp/qt,radekp/qt,radekp/qt,igor-sfdc/qt-wk,igor-sfdc/qt-wk,radekp/qt,igor-sfdc/qt-wk,pruiz/wkhtmltopdf-qt,pruiz/wkhtmltopdf-qt,radekp/qt,igor-sfdc/qt-wk,igor-sfdc/qt-wk,pruiz/wkhtmltopdf-qt,pruiz/wkhtmltopdf-qt