Remove last dlist from browser window.

This commit is contained in:
2026-01-08 07:25:41 -05:00
parent 24d68c53e3
commit a93ed33c22
3 changed files with 15 additions and 21 deletions
+13 -19
View File
@@ -64,7 +64,6 @@ BrowserWindow *a_Bw_new(void)
bw->meta_refresh_status = 0; bw->meta_refresh_status = 0;
bw->meta_refresh_url = NULL; bw->meta_refresh_url = NULL;
bw->ImageClients = dList_new(8);
bw->NumImages = 0; bw->NumImages = 0;
bw->NumImagesGot = 0; bw->NumImagesGot = 0;
bw->NumPendingStyleSheets = 0; bw->NumPendingStyleSheets = 0;
@@ -90,9 +89,6 @@ BrowserWindow::~BrowserWindow()
if (bws[i] == this) { if (bws[i] == this) {
a_List_remove(bws, i, num_bws); a_List_remove(bws, i, num_bws);
dList_free(this->ImageClients);
break; break;
} }
} }
@@ -114,12 +110,12 @@ void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
if (Root) { if (Root) {
bw->RootClients.push_back(Key); bw->RootClients.push_back(Key);
} else { } else {
dList_append(bw->ImageClients, INT2VOIDP(Key)); bw->ImageClients.push_back( Key);
bw->NumImages++; bw->NumImages++;
/* --Images progress-bar stuff-- */ /* --Images progress-bar stuff-- */
a_UIcmd_set_img_prog(bw, bw->NumImagesGot, bw->NumImages, 1); a_UIcmd_set_img_prog(bw, bw->NumImagesGot, bw->NumImages, 1);
} }
if (bw->RootClients.size() + dList_length(bw->ImageClients) == 1) if (bw->RootClients.size() + bw->ImageClients.size() == 1)
a_UIcmd_set_buttons_sens(bw); a_UIcmd_set_buttons_sens(bw);
} }
@@ -130,17 +126,18 @@ void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
*/ */
int a_Bw_remove_client(BrowserWindow *bw, int ClientKey) int a_Bw_remove_client(BrowserWindow *bw, int ClientKey)
{ {
void *data; bool found= false;
auto where= std::find( begin( bw->RootClients ), end( bw->RootClients ), ClientKey ); auto where= std::find( begin( bw->RootClients ), end( bw->RootClients ), ClientKey );
if (where != end( bw->RootClients )) { if (where != end( bw->RootClients )) {
bw->RootClients.erase( where ); bw->RootClients.erase( where );
} else if ((data = dList_find(bw->ImageClients, INT2VOIDP(ClientKey)))) { } else if (auto data = std::find( begin( bw->ImageClients ), end( bw->ImageClients ), ClientKey ); data != end( bw->ImageClients ) ) {
dList_remove_fast(bw->ImageClients, data); found= *data;
bw->ImageClients.erase( data );
++bw->NumImagesGot; ++bw->NumImagesGot;
} }
return data ? 0 : 1; return not found;
} }
/** /**
@@ -165,7 +162,6 @@ void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
*/ */
void a_Bw_stop_clients(BrowserWindow *bw, int flags) void a_Bw_stop_clients(BrowserWindow *bw, int flags)
{ {
void *data;
int which; int which;
if (flags & BW_Root) { if (flags & BW_Root) {
@@ -178,10 +174,11 @@ void a_Bw_stop_clients(BrowserWindow *bw, int flags)
if (flags & BW_Img) { if (flags & BW_Img) {
/* Remove image clients */ /* Remove image clients */
while ((data = dList_nth_data(bw->ImageClients, 0))) { for( const auto &data: bw->ImageClients )
a_Capi_stop_client(VOIDP2INT(data), (flags & BW_Force)); {
dList_remove_fast(bw->ImageClients, data); a_Capi_stop_client(data, (flags & BW_Force));
} }
bw->ImageClients.clear();
} }
} }
@@ -264,15 +261,12 @@ void a_Bw_remove_doc(BrowserWindow *bw, DilloHtml *vdoc)
*/ */
void a_Bw_cleanup(BrowserWindow *bw) void a_Bw_cleanup(BrowserWindow *bw)
{ {
void *data;
/* Remove root clients */ /* Remove root clients */
bw->RootClients.clear(); bw->RootClients.clear();
/* Remove image clients */ /* Remove image clients */
while ((data = dList_nth_data(bw->ImageClients, 0))) { bw->ImageClients.clear();
dList_remove_fast(bw->ImageClients, data);
}
/* Remove PageUrls */ /* Remove PageUrls */
bw->PageUrls.clear(); bw->PageUrls.clear();
+1 -1
View File
@@ -57,7 +57,7 @@ struct BrowserWindow {
/** A list of active cache clients in the window (The primary Key) */ /** A list of active cache clients in the window (The primary Key) */
std::vector< int > RootClients; std::vector< int > RootClients;
/** Image Keys for all active connections in the window */ /** Image Keys for all active connections in the window */
Dlist *ImageClients; std::vector< int > ImageClients;
/** Number of images in the page */ /** Number of images in the page */
int NumImages; int NumImages;
/** Number of images already loaded */ /** Number of images already loaded */
+1 -1
View File
@@ -1559,7 +1559,7 @@ void a_UIcmd::a_UIcmd_set_buttons_sens(BrowserWindow *bw)
int sens; int sens;
// Stop // Stop
sens = (dList_length(bw->ImageClients) || bw->RootClients.size()); sens = (bw->ImageClients.size() || bw->RootClients.size());
BW2UI(bw)->button_set_sens(UI_STOP, sens); BW2UI(bw)->button_set_sens(UI_STOP, sens);
// Back // Back
sens = (a_Nav_stack_ptr(bw) > 0); sens = (a_Nav_stack_ptr(bw) > 0);