From 6d99dd00975e27693031e614ea5ff9a079c9ae0d Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 6 Oct 2015 22:30:05 +0200 Subject: [PATCH] use make_unique --- abstractattachment.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/abstractattachment.cpp b/abstractattachment.cpp index 5c457af..d14fc82 100644 --- a/abstractattachment.cpp +++ b/abstractattachment.cpp @@ -3,6 +3,8 @@ #include "./mediafileinfo.h" #include "./exceptions.h" +#include + #include using namespace std; @@ -123,16 +125,17 @@ void AbstractAttachment::clear() */ void AbstractAttachment::setFile(const std::string &path) { - m_data.reset(new FileDataBlock(path)); - FileDataBlock &data = *static_cast(m_data.get()); - string fileName = data.fileInfo()->fileName(); + m_data.reset(); + auto file = make_unique(path); + const auto fileName = file->fileInfo()->fileName(); if(!fileName.empty()) { m_name = fileName; } - const char *mimeType = data.fileInfo()->mimeType(); + const char *mimeType = file->fileInfo()->mimeType(); if(*mimeType) { m_mimeType = mimeType; } + m_data = move(file); } } // namespace Media