Clean up pointer use:

* Use unique_ptr for Actions instead of manual memory management
 * Use unique_ptr in KeywordDatabase
 * Use unique_ptr instead of shared_ptr for file formats
 * Don't pass shared_ptr to Reader/Writer, use references instead
Also
 * Switch to C++17 so we can use map::try_emplace
This commit is contained in:
Twan van Laarhoven
2020-04-25 21:30:05 +02:00
parent 708b4389a0
commit 64ea1d7322
57 changed files with 363 additions and 385 deletions
+4 -5
View File
@@ -82,15 +82,14 @@ bool DownloadableInstallerList::download() {
wxThread::ExitCode DownloadableInstallerList::Thread::Entry() {
// open url
wxURL url(settings.installer_list_url);
wxInputStream* isP = url.GetInputStream();
if (!isP) {
unique_ptr<wxInputStream> stream(url.GetInputStream());
if (!stream) {
wxMutexLocker l(downloadable_installers.lock);
downloadable_installers.status = DONE;
return 0;
}
InputStreamP is(isP);
// Read installer list
Reader reader(is, nullptr, _("installers"), true);
Reader reader(*stream, nullptr, _("installers"), true);
vector<DownloadableInstallerP> installers;
reader.handle(_("installers"),installers);
// done
@@ -344,7 +343,7 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
}
// download installer
wxURL url(ip->installer->installer_url);
wxInputStream* is = url.GetInputStream();
unique_ptr<wxInputStream> is(url.GetInputStream());
if (!is) {
throw Error(_ERROR_2_("can't download installer", ip->description->name, ip->installer->installer_url));
}