diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-24 20:04:14 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-24 20:04:14 +0100 |
commit | 79aa5c60b38da8403ec2550247143c8f4b45d323 (patch) | |
tree | a8e1d29657ebc48509afaef8c979c43437a81c0d | |
parent | 21ce1398513a085d44ef89a9250541769ad11e46 (diff) |
gui, opentrack: simplify std::function/unique_ptr usage
Reported by: ElDesalmado
-rw-r--r-- | gui/init.cpp | 4 | ||||
-rw-r--r-- | gui/init.hpp | 3 | ||||
-rw-r--r-- | variant/default/main.cpp | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/gui/init.cpp b/gui/init.cpp index 07f6c6b1..77d90212 100644 --- a/gui/init.cpp +++ b/gui/init.cpp @@ -238,7 +238,7 @@ static int run_window(std::unique_ptr<QWidget> main_window) return status; } -int otr_main(int argc, char** argv, std::function<QWidget*()> const& make_main_window) +int otr_main(int argc, char** argv, std::function<std::unique_ptr<QWidget>()> const& make_main_window) { set_fp_mask(); #ifdef OTR_X11_THREADS @@ -286,7 +286,7 @@ int otr_main(int argc, char** argv, std::function<QWidget*()> const& make_main_w } } - int ret = run_window(std::unique_ptr<QWidget>(make_main_window())); + int ret = run_window(make_main_window()); #if 0 // msvc crashes in Qt plugin system's dtor diff --git a/gui/init.hpp b/gui/init.hpp index 7c437bcb..4274f437 100644 --- a/gui/init.hpp +++ b/gui/init.hpp @@ -3,9 +3,10 @@ #include "export.hpp" #include <functional> +#include <memory> #include <QWidget> -OTR_GUI_EXPORT int otr_main(int argc, char** argv, std::function<QWidget*()> const& make_main_window); +OTR_GUI_EXPORT int otr_main(int argc, char** argv, std::function<std::unique_ptr<QWidget>()> const& make_main_window); // XXX TODO need split MainWindow into mixins each implementing part of the functionality diff --git a/variant/default/main.cpp b/variant/default/main.cpp index 0038583b..2c1dc607 100644 --- a/variant/default/main.cpp +++ b/variant/default/main.cpp @@ -11,7 +11,7 @@ int main(int argc, char** argv) { - return run_application(argc, argv, [] { return new main_window; }); + return run_application(argc, argv, [] { return std::make_unique<main_window>(); }); } #if defined _MSC_VER |