From a3cd010c82a56ae2297cb6716789b83f6b2403fb Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 24 Sep 2020 13:46:15 +0200 Subject: [PATCH] Start: [skip ci] replace QTextStream and its manipulators with stringstream to avoid deprecation warnings with Qt 5.15 --- src/Mod/Start/Gui/Workbench.cpp | 52 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/Mod/Start/Gui/Workbench.cpp b/src/Mod/Start/Gui/Workbench.cpp index 41baf3deaf..282c9361a9 100644 --- a/src/Mod/Start/Gui/Workbench.cpp +++ b/src/Mod/Start/Gui/Workbench.cpp @@ -25,7 +25,6 @@ #ifndef _PreComp_ # include -# include #endif #include "Workbench.h" @@ -83,39 +82,38 @@ void StartGui::Workbench::loadStartPage() try { QByteArray utf8Title = title.toUtf8(); std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(utf8Title); - QByteArray cmd; - QTextStream str(&cmd); - str << "import WebGui,sys,Start" << endl; - str << "from StartPage import StartPage" << endl; - str << endl; - str << "class WebPage(object):" << endl; - str << " def __init__(self):" << endl; - str << " self.browser=WebGui.openBrowserWindow(u'" << escapedstr.c_str() << "')" << endl; + std::stringstream str; + str << "import WebGui,sys,Start" << std::endl; + str << "from StartPage import StartPage" << std::endl; + str << std::endl; + str << "class WebPage(object):" << std::endl; + str << " def __init__(self):" << std::endl; + str << " self.browser=WebGui.openBrowserWindow(u'" << escapedstr.c_str() << "')" << std::endl; #if defined(FC_OS_WIN32) - str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl; + str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl; #else - str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl; + str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl; #endif - str << " def onChange(self, par, reason):" << endl; - str << " if reason == 'RecentFiles':" << endl; + str << " def onChange(self, par, reason):" << std::endl; + str << " if reason == 'RecentFiles':" << std::endl; #if defined(FC_OS_WIN32) - str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl; + str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl; #else - str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl; + str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl; #endif - str << endl; - str << "class WebView(object):" << endl; - str << " def __init__(self):" << endl; - str << " self.pargrp = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/RecentFiles')" << endl; - str << " self.webPage = WebPage()" << endl; - str << " self.pargrp.Attach(self.webPage)" << endl; - str << " def __del__(self):" << endl; - str << " self.pargrp.Detach(self.webPage)" << endl; - str << endl; - str << "webView=WebView()" << endl; - str << "StartPage.checkPostOpenStartPage()" << endl; + str << std::endl; + str << "class WebView(object):" << std::endl; + str << " def __init__(self):" << std::endl; + str << " self.pargrp = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/RecentFiles')" << std::endl; + str << " self.webPage = WebPage()" << std::endl; + str << " self.pargrp.Attach(self.webPage)" << std::endl; + str << " def __del__(self):" << std::endl; + str << " self.pargrp.Detach(self.webPage)" << std::endl; + str << std::endl; + str << "webView=WebView()" << std::endl; + str << "StartPage.checkPostOpenStartPage()" << std::endl; - Base::Interpreter().runString(cmd); + Base::Interpreter().runString(str.str().c_str()); // Gui::Command::runCommand(Gui::Command::Gui, cmd); } catch (const Base::Exception& e) {