1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
Michael Vetter c6cf27e4e1
Merge pull request #1952 from H3rnand3zzz/fix/alt-underscroll
Fix underscrolling issue for alternative scrolling
2024-03-01 13:02:34 +01:00
Michael Vetter e5eb0f41f3
Merge pull request #1958 from ike08/fix/no-download-twice
Fix unable to download item twice
2024-03-01 12:57:54 +01:00
ike08 23fa4750ff Fix unable to download item twice
## Summary

Partial fix for https://github.com/profanity-im/profanity/issues/1939  

> When doing the same in an unencrypted (no e2ee) chat there is no Downloading… message at all but the file is downloaded.  

Download a file twice with `/url save`, the second download will not print download progress to the window.  

The cause is `HTTPDownload`'s `silent` variable is not initialized; so, `silent` points to a second-hand stack memory address with old data. `silent` references data, so the `if` statement will fail in **src/tools/http_download.c:206** and download progress will not print to the window.  

The fix is to initialize `silent` in both encrypted and unencrypted file download scenarios.  

## Testing

Valgrind: Yes  

- `/url save` without OMEMO  
  **SUCCESS**: Try three times with the same URL and download status will display every time.  

- `/url save` with OMEMO  
  **SUCCESS**: Try three times with the same URL and download status will display every time.  

- `/plugins install https://raw.githubusercontent.com/profanity-im/profanity-plugins/master/stable/sounds.py`  
  **SUCCESS**: Try once and download progress is hidden.
2024-02-28 07:23:59 -07:00
John Hernandez 4030b0936e
Fix underscrolling issue for alternative scrolling
When user was scrolling down using alt + mouse wheel/arrows, he would be
stuck in most of the cases after the buffer finishes
due to the part of code that moves the "cursor" up to show full last page.

New algorithm considers close to border cursor as passing for
DB loading condition,
at the same time it calculates offset, allowing flexible scroll size.

The problem was introduced by  @H3rnand3zzz in the following commit:
23692fedff
2024-01-25 20:25:01 +01:00
3 changed files with 10 additions and 8 deletions

View File

@ -9447,6 +9447,7 @@ _url_http_method(ProfWin* window, const char* cmd_template, gchar* url, gchar* p
download->filename = strdup(filename);
download->id = strdup(id);
download->cmd_template = cmd_template ? strdup(cmd_template) : NULL;
download->silent = FALSE;
pthread_create(&(download->worker), NULL, &http_file_get, download);
http_download_add_download(download);

View File

@ -110,6 +110,7 @@ aesgcm_file_get(void* userdata)
http_dl->url = strdup(https_url);
http_dl->filename = strdup(tmpname);
http_dl->cmd_template = NULL;
http_dl->silent = FALSE;
aesgcm_dl->http_dl = http_dl;
http_file_get(http_dl); // TODO(wstrm): Verify result.

View File

@ -694,7 +694,7 @@ win_page_down(ProfWin* window, int scroll_size)
*page_start += scroll_size;
// Scrolled down after reaching the bottom of the page
if ((*page_start == total_rows || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
int bf_size = buffer_size(window->layout->buffer);
if (bf_size > 0) {
ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1);
@ -708,19 +708,19 @@ win_page_down(ProfWin* window, int scroll_size)
g_date_time_unref(now);
int offset = last_entry->y_end_pos - 1;
*page_start = offset;
*page_start = offset - page_space + scroll_size;
}
}
total_rows = getcury(window->layout->win);
// only got half a screen, show full screen
if ((total_rows - (*page_start)) < page_space)
// near the end, but will display only part of the page space, move a bit back to show full page
if ((total_rows - *page_start) < page_space) {
*page_start = total_rows - page_space;
// went past end, show full screen
else if (*page_start >= total_rows)
// went past end, show last page
} else if (*page_start >= total_rows) {
*page_start = total_rows - page_space - 1;
}
window->layout->paged = 1;
@ -730,7 +730,7 @@ win_page_down(ProfWin* window, int scroll_size)
}
// switch off page if last line and space line visible
if ((total_rows) - *page_start == page_space) {
if (total_rows - *page_start == page_space) {
window->layout->paged = 0;
}
}