mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Use helper functions to construct smart pointers
This commit is contained in:
parent
ca01b049a6
commit
2157e500ef
@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
|||||||
try {
|
try {
|
||||||
// Create Application
|
// Create Application
|
||||||
const QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString();
|
const QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString();
|
||||||
std::unique_ptr<Application> app(new Application(appId, argc, argv));
|
auto app = std::make_unique<Application>(appId, argc, argv);
|
||||||
|
|
||||||
const QBtCommandLineParameters params = app->commandLineArgs();
|
const QBtCommandLineParameters params = app->commandLineArgs();
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ int main(int argc, char *argv[])
|
|||||||
if (params.shouldDaemonize) {
|
if (params.shouldDaemonize) {
|
||||||
app.reset(); // Destroy current application
|
app.reset(); // Destroy current application
|
||||||
if (daemon(1, 0) == 0) {
|
if (daemon(1, 0) == 0) {
|
||||||
app.reset(new Application(appId, argc, argv));
|
app = std::make_unique<Application>(appId, argc, argv);
|
||||||
if (app->isRunning()) {
|
if (app->isRunning()) {
|
||||||
// Another instance had time to start.
|
// Another instance had time to start.
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -60,7 +60,7 @@ std::shared_ptr<lt::torrent_plugin> NativeSessionExtension::new_torrent(const lt
|
|||||||
#else
|
#else
|
||||||
boost::shared_ptr<lt::torrent_plugin> NativeSessionExtension::new_torrent(const lt::torrent_handle &torrentHandle, void *)
|
boost::shared_ptr<lt::torrent_plugin> NativeSessionExtension::new_torrent(const lt::torrent_handle &torrentHandle, void *)
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<lt::torrent_plugin> {new NativeTorrentExtension {torrentHandle}};
|
return boost::make_shared<NativeTorrentExtension>(torrentHandle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ void SearchPluginManager::update()
|
|||||||
if (!engineElem.isNull()) {
|
if (!engineElem.isNull()) {
|
||||||
const QString pluginName = engineElem.tagName();
|
const QString pluginName = engineElem.tagName();
|
||||||
|
|
||||||
std::unique_ptr<PluginInfo> plugin {new PluginInfo {}};
|
auto plugin = std::make_unique<PluginInfo>();
|
||||||
plugin->name = pluginName;
|
plugin->name = pluginName;
|
||||||
plugin->version = getPluginVersion(pluginPath(pluginName));
|
plugin->version = getPluginVersion(pluginPath(pluginName));
|
||||||
plugin->fullName = engineElem.elementsByTagName("name").at(0).toElement().text();
|
plugin->fullName = engineElem.elementsByTagName("name").at(0).toElement().text();
|
||||||
|
@ -327,7 +327,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
|
|||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
const std::wstring pathW {path.toStdWString()};
|
const std::wstring pathW {path.toStdWString()};
|
||||||
std::unique_ptr<wchar_t[]> volumePath {new wchar_t[path.length() + 1] {}};
|
auto volumePath = std::make_unique<wchar_t[]>(path.length() + 1);
|
||||||
if (!::GetVolumePathNameW(pathW.c_str(), volumePath.get(), (path.length() + 1)))
|
if (!::GetVolumePathNameW(pathW.c_str(), volumePath.get(), (path.length() + 1)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const QString msg = QCoreApplication::translate("misc", "qBittorrent will shutdown the computer now because all downloads are complete.");
|
const QString msg = QCoreApplication::translate("misc", "qBittorrent will shutdown the computer now because all downloads are complete.");
|
||||||
std::unique_ptr<wchar_t[]> msgWchar(new wchar_t[msg.length() + 1] {});
|
auto msgWchar = std::make_unique<wchar_t[]>(msg.length() + 1);
|
||||||
msg.toWCharArray(msgWchar.get());
|
msg.toWCharArray(msgWchar.get());
|
||||||
::InitiateSystemShutdownW(nullptr, msgWchar.get(), 10, true, false);
|
::InitiateSystemShutdownW(nullptr, msgWchar.get(), 10, true, false);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ namespace Utils
|
|||||||
|
|
||||||
path += source;
|
path += source;
|
||||||
|
|
||||||
std::unique_ptr<wchar_t[]> pathWchar(new wchar_t[path.length() + 1] {});
|
auto pathWchar = std::make_unique<wchar_t[]>(path.length() + 1);
|
||||||
path.toWCharArray(pathWchar.get());
|
path.toWCharArray(pathWchar.get());
|
||||||
|
|
||||||
return reinterpret_cast<T>(
|
return reinterpret_cast<T>(
|
||||||
|
@ -268,7 +268,7 @@ bool AddNewTorrentDialog::loadTorrentFile(const QString &torrentPath)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_torrentGuard.reset(new TorrentFileGuard(decodedPath));
|
m_torrentGuard = std::make_unique<TorrentFileGuard>(decodedPath);
|
||||||
|
|
||||||
return loadTorrentImpl();
|
return loadTorrentImpl();
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_torrentGuard.reset(new TorrentFileGuard(QString()));
|
m_torrentGuard = std::make_unique<TorrentFileGuard>();
|
||||||
m_hash = magnetUri.hash();
|
m_hash = magnetUri.hash();
|
||||||
// Prevent showing the dialog if download is already present
|
// Prevent showing the dialog if download is already present
|
||||||
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
|
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
|
||||||
@ -678,7 +678,7 @@ void AddNewTorrentDialog::handleDownloadFinished(const Net::DownloadResult &resu
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_torrentGuard.reset(new TorrentFileGuard);
|
m_torrentGuard = std::make_unique<TorrentFileGuard>();
|
||||||
|
|
||||||
if (loadTorrentImpl())
|
if (loadTorrentImpl())
|
||||||
open();
|
open();
|
||||||
|
Loading…
Reference in New Issue
Block a user