diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-03-23 04:05:04 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-04-04 14:19:43 +0200 |
commit | 810e62b8ba9c0fa5152592ef6b01400bfcfe59c0 (patch) | |
tree | dcdf418abba843fa154acbe7e22e7a016c9e3469 /vcl/inc | |
parent | ae1e23651a6d2e97d39bbe46bab83b7982d19611 (diff) |
Qt5 / KDE5 refactor create_SalInstance
Move most common code into Qt5Instance (static) functions.
Not much saved with regard to LOC, but since the code was
95% C'n'P, I hope it'll be less error prone this way.
Also handle all QApplication argument pointers via
std::unique_ptr from the beginning.
Change-Id: I87b2f571d398db7ccce3e740f16205b251be4ced
Reviewed-on: https://gerrit.libreoffice.org/69578
Tested-by: Jenkins
Reviewed-by: Aleksei Nikiforov <darktemplar@basealt.ru>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/qt5/Qt5Instance.hxx | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx index 52153846faa1..a9be3581f64b 100644 --- a/vcl/inc/qt5/Qt5Instance.hxx +++ b/vcl/inc/qt5/Qt5Instance.hxx @@ -27,12 +27,21 @@ #include <QtCore/QObject> +#include <cstdlib> #include <functional> +#include <memory> +#include <vector> class QApplication; class SalYieldMutex; class SalFrame; +struct StdFreeCStr +{ + void operator()(char* arg) const noexcept { std::free(arg); } +}; +using FreeableCStr = std::unique_ptr<char[], StdFreeCStr>; + class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject, public SalGenericInstance, public SalUserEventList @@ -44,9 +53,8 @@ class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject, const bool m_bUseCairo; std::unordered_map<OUString, css::uno::Reference<css::uno::XInterface>> m_aClipboards; -public: std::unique_ptr<QApplication> m_pQApplication; - std::unique_ptr<char* []> m_pFakeArgvFreeable; + std::vector<FreeableCStr> m_pFakeArgvFreeable; std::unique_ptr<char* []> m_pFakeArgv; std::unique_ptr<int> m_pFakeArgc; @@ -61,9 +69,17 @@ Q_SIGNALS: void deleteObjectLaterSignal(QObject* pObject); public: - explicit Qt5Instance(bool bUseCairo = false); + explicit Qt5Instance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo = false); virtual ~Qt5Instance() override; + // handle common SalInstance setup + static void AllocFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv, + std::unique_ptr<int>& rFakeArgc, + std::vector<FreeableCStr>& rFakeArgvFreeable); + void MoveFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv, std::unique_ptr<int>& rFakeArgc, + std::vector<FreeableCStr>& rFakeArgvFreeable); + static std::unique_ptr<QApplication> CreateQApplication(int& nArgc, char** pArgv); + void RunInMainThread(std::function<void()> func); virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override; |