Track another URL by smart pointer.

This commit is contained in:
2025-09-07 17:52:27 -04:00
parent dea296a063
commit 77859c704e

View File

@ -368,7 +368,7 @@ static void setColors()
/** /**
* Given a command line argument, build a DilloUrl for it. * Given a command line argument, build a DilloUrl for it.
*/ */
static DilloUrl *makeStartUrl(char *str, bool local) static std::unique_ptr< DilloUrl > makeStartUrl(char *str, bool local)
{ {
using namespace std::literals::string_literals; using namespace std::literals::string_literals;
std::string url_str; std::string url_str;
@ -392,7 +392,7 @@ static DilloUrl *makeStartUrl(char *str, bool local)
if (local) if (local)
a_Url_set_flags(start_url.get(), URL_FLAGS(start_url) | URL_SpamSafe); a_Url_set_flags(start_url.get(), URL_FLAGS(start_url) | URL_SpamSafe);
return start_url.release(); return start_url;
} }
/* /*
@ -578,21 +578,20 @@ int main(int argc, char **argv)
} }
} else { } else {
for (int i = idx; i < argc; i++) { for (int i = idx; i < argc; i++) {
DilloUrl *start_url = makeStartUrl(argv[i], local); auto start_url = makeStartUrl(argv[i], local);
if (i > idx) { if (i > idx) {
if (prefs.middle_click_opens_new_tab) { if (prefs.middle_click_opens_new_tab) {
/* user must prefer tabs */ /* user must prefer tabs */
const int focus = 1; const int focus = 1;
a_UIcmd_open_url_nt(bw, start_url, focus); a_UIcmd_open_url_nt(bw, start_url.get(), focus);
} else { } else {
a_UIcmd_open_url_nw(bw, start_url); a_UIcmd_open_url_nw(bw, start_url.get());
} }
} else { } else {
a_UIcmd_open_url(bw, start_url); a_UIcmd_open_url(bw, start_url.get());
a_UIcmd_set_location_text(bw, URL_STR(start_url)); a_UIcmd_set_location_text(bw, URL_STR(start_url.get()));
} }
delete start_url;
} }
} }