Implicit dtor for DilloHtmlImage.
This commit is contained in:
24
src/html.cc
24
src/html.cc
@ -554,7 +554,7 @@ DilloHtml::~DilloHtml()
|
|||||||
|
|
||||||
for (int i = 0; i < images->size(); i++) {
|
for (int i = 0; i < images->size(); i++) {
|
||||||
DilloHtmlImage *img = images->get(i);
|
DilloHtmlImage *img = images->get(i);
|
||||||
delete img->url;
|
img->url.reset(); // Was: delete img->url;
|
||||||
img->image.reset(); // Was: a_Image_unref(img->image);
|
img->image.reset(); // Was: a_Image_unref(img->image);
|
||||||
dFree(img);
|
dFree(img);
|
||||||
}
|
}
|
||||||
@ -705,8 +705,8 @@ void DilloHtml::loadImages (const DilloUrl *pattern)
|
|||||||
|
|
||||||
if (hi->image) {
|
if (hi->image) {
|
||||||
assert(hi->url);
|
assert(hi->url);
|
||||||
if ((!pattern) || (!a_Url_cmp(hi->url, pattern))) {
|
if ((!pattern) || (!a_Url_cmp(hi->url.get(), pattern))) {
|
||||||
if (Html_load_image(bw, hi->url, requester, hi->image)) {
|
if (Html_load_image(bw, hi->url.get(), requester, hi->image)) {
|
||||||
hi->image = nullptr; // web owns it now
|
hi->image = nullptr; // web owns it now
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -757,7 +757,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
|
|||||||
if (link != -1)
|
if (link != -1)
|
||||||
linkurl = html->links.at(link).get();
|
linkurl = html->links.at(link).get();
|
||||||
const bool_t loaded_img = (html->images->get(img)->image == NULL);
|
const bool_t loaded_img = (html->images->get(img)->image == NULL);
|
||||||
a_UIcmd_image_popup(bw, html->images->get(img)->url, loaded_img,
|
a_UIcmd_image_popup(bw, html->images->get(img)->url.get(), loaded_img,
|
||||||
html->page_url, linkurl);
|
html->page_url, linkurl);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
@ -785,7 +785,7 @@ bool DilloHtml::HtmlLinkReceiver::click (Widget *widget, int link, int img,
|
|||||||
// clicked an image that has not already been loaded
|
// clicked an image that has not already been loaded
|
||||||
if (event->button == 1){
|
if (event->button == 1){
|
||||||
// load all instances of this image
|
// load all instances of this image
|
||||||
DilloUrl *pattern = html->images->get(img)->url;
|
DilloUrl *pattern = html->images->get(img)->url.get();
|
||||||
html->loadImages(pattern);
|
html->loadImages(pattern);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2108,12 +2108,12 @@ std::shared_ptr< DilloImage > a_Html_image_new(DilloHtml *html, const char *tag,
|
|||||||
{
|
{
|
||||||
bool load_now;
|
bool load_now;
|
||||||
const char *attrbuf;
|
const char *attrbuf;
|
||||||
DilloUrl *url;
|
std::unique_ptr< DilloUrl > url;
|
||||||
std::shared_ptr< DilloImage > image;
|
std::shared_ptr< DilloImage > image;
|
||||||
|
|
||||||
if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "src")) ||
|
if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "src")) ||
|
||||||
!(url = a_Html_url_new(html, attrbuf, NULL, 0).release()))
|
!(url = a_Html_url_new(html, attrbuf, NULL, 0)))
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
auto alt_ptr = a_Html_get_attr_wdef(html, tag, tagsize, "alt", NULL);
|
auto alt_ptr = a_Html_get_attr_wdef(html, tag, tagsize, "alt", NULL);
|
||||||
if (!alt_ptr.has_value() || alt_ptr.value().empty()) {
|
if (!alt_ptr.has_value() || alt_ptr.value().empty()) {
|
||||||
@ -2132,15 +2132,15 @@ std::shared_ptr< DilloImage > a_Html_image_new(DilloHtml *html, const char *tag,
|
|||||||
image->fg_color = HT2TB(html)->getFgColor()->getColor();
|
image->fg_color = HT2TB(html)->getFgColor()->getColor();
|
||||||
|
|
||||||
DilloHtmlImage *hi = new DilloHtmlImage{};
|
DilloHtmlImage *hi = new DilloHtmlImage{};
|
||||||
hi->url = url;
|
hi->url = std::move( url );
|
||||||
html->images->increase();
|
html->images->increase();
|
||||||
html->images->set(html->images->size() - 1, hi);
|
html->images->set(html->images->size() - 1, hi);
|
||||||
|
|
||||||
load_now = prefs.load_images ||
|
load_now = prefs.load_images ||
|
||||||
!dStrAsciiCasecmp(URL_SCHEME(url), "data") ||
|
!dStrAsciiCasecmp(URL_SCHEME(hi->url.get()), "data") ||
|
||||||
(a_Capi_get_flags_with_redirection(url) & CAPI_IsCached);
|
(a_Capi_get_flags_with_redirection(hi->url.get()) & CAPI_IsCached);
|
||||||
|
|
||||||
if (load_now && Html_load_image(html->bw, url, html->page_url, image)) {
|
if (load_now && Html_load_image(html->bw, hi->url.get(), html->page_url, image)) {
|
||||||
// hi->image is NULL if dillo tries to load the image immediately
|
// hi->image is NULL if dillo tries to load the image immediately
|
||||||
hi->image = nullptr;
|
hi->image = nullptr;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -119,7 +119,7 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct DilloHtmlImage {
|
struct DilloHtmlImage {
|
||||||
DilloUrl *url;
|
std::unique_ptr< DilloUrl > url;
|
||||||
std::shared_ptr< DilloImage > image;
|
std::shared_ptr< DilloImage > image;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user