modernize: Use std::make_unique
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 9 Sep 2018 22:04:11 +0000 (00:04 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 10:06:43 +0000 (11:06 +0100)
src/core/coreapplication.cpp
src/qtui/qtmultimedianotificationbackend.cpp
src/qtui/qtui.cpp
src/qtui/qtuiapplication.cpp

index d662820..8fbf4aa 100644 (file)
@@ -32,7 +32,7 @@ CoreApplication::CoreApplication(int &argc, char **argv)
 
 void CoreApplication::init()
 {
 
 void CoreApplication::init()
 {
-    _core.reset(new Core{}); // FIXME C++14: std::make_unique
+    _core = std::make_unique<Core>();
     _core->init();
 }
 
     _core->init();
 }
 
index afffd04..3a32cb1 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QFileDialog>
 #include <QUrl>
 
 #include <QFileDialog>
 #include <QUrl>
+#include <memory>
 
 #include "clientsettings.h"
 #include "icon.h"
 
 #include "clientsettings.h"
 #include "icon.h"
@@ -85,7 +86,7 @@ void QtMultimediaNotificationBackend::createMediaObject(const QString &file)
         return;
     }
 
         return;
     }
 
-    _media.reset(new QMediaPlayer);
+    _media = std::make_unique<QMediaPlayer>();
     _media->setMedia(QUrl::fromLocalFile(file));
 }
 
     _media->setMedia(QUrl::fromLocalFile(file));
 }
 
@@ -177,7 +178,7 @@ void QtMultimediaNotificationBackend::ConfigWidget::on_play_clicked()
 {
     if (_audioAvailable) {
         if (!ui.filename->text().isEmpty()) {
 {
     if (_audioAvailable) {
         if (!ui.filename->text().isEmpty()) {
-            _audioPreview.reset(new QMediaPlayer);
+            _audioPreview = std::make_unique<QMediaPlayer>();
             _audioPreview->setMedia(QUrl::fromLocalFile(ui.filename->text()));
             _audioPreview->play();
         }
             _audioPreview->setMedia(QUrl::fromLocalFile(ui.filename->text()));
             _audioPreview->play();
         }
index 9bd8157..d438c20 100644 (file)
@@ -25,6 +25,7 @@
 #include <QFileInfo>
 #include <QIcon>
 #include <QStringList>
 #include <QFileInfo>
 #include <QIcon>
 #include <QStringList>
+#include <memory>
 
 #include "abstractnotificationbackend.h"
 #include "buffermodel.h"
 
 #include "abstractnotificationbackend.h"
 #include "buffermodel.h"
@@ -79,7 +80,7 @@ void QtUi::init()
     setContextMenuActionProvider(new ContextMenuActionProvider(this));
     setToolBarActionProvider(new ToolBarActionProvider(this));
 
     setContextMenuActionProvider(new ContextMenuActionProvider(this));
     setToolBarActionProvider(new ToolBarActionProvider(this));
 
-    _mainWin.reset(new MainWin());  // TODO C++14: std::make_unique
+    _mainWin = std::make_unique<MainWin>();
     setMainWidget(_mainWin.get());
 
     connect(_mainWin.get(), SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &)));
     setMainWidget(_mainWin.get());
 
     connect(_mainWin.get(), SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &)));
@@ -355,7 +356,7 @@ void QtUi::refreshIconTheme()
     // Since we can't get notified when the system theme changes, this means that a restart may be required
     // to apply a theme change... but you can't have everything, I guess.
     if (!_dummyThemeDir) {
     // Since we can't get notified when the system theme changes, this means that a restart may be required
     // to apply a theme change... but you can't have everything, I guess.
     if (!_dummyThemeDir) {
-        _dummyThemeDir.reset(new QTemporaryDir{});
+        _dummyThemeDir = std::make_unique<QTemporaryDir>();
         if (!_dummyThemeDir->isValid() || !QDir{_dummyThemeDir->path()}.mkpath("icons/quassel-icon-proxy/apps/32")) {
             qWarning() << "Could not create temporary directory for proxying the system icon theme, using fallback";
             QIcon::setThemeName(fallbackTheme);
         if (!_dummyThemeDir->isValid() || !QDir{_dummyThemeDir->path()}.mkpath("icons/quassel-icon-proxy/apps/32")) {
             qWarning() << "Could not create temporary directory for proxying the system icon theme, using fallback";
             QIcon::setThemeName(fallbackTheme);
index 7ae97df..ac9562f 100644 (file)
@@ -50,7 +50,7 @@ void QtUiApplication::init()
         throw ExitException{EXIT_FAILURE, tr("Could not load or upgrade client settings!")};
     }
 
         throw ExitException{EXIT_FAILURE, tr("Could not load or upgrade client settings!")};
     }
 
-    _client.reset(new Client(std::unique_ptr<QtUi>(new QtUi())));  // TODO C++14: std::make_unique
+    _client = std::make_unique<Client>(std::make_unique<QtUi>());
 
     // Init UI only after the event loop has started
     // TODO Qt5: Make this a lambda
 
     // Init UI only after the event loop has started
     // TODO Qt5: Make this a lambda