1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 23:53:03 +01:00

Use correct integer types to fix groupchat peer scrolling bug

This commit is contained in:
jfreegman 2019-03-26 23:05:24 -04:00
parent 2e39bee05a
commit 2cbe8fa880
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 8 additions and 8 deletions

View File

@ -428,7 +428,7 @@ static void groupchat_onGroupPeerNameChange(ToxWindow *self, Tox *m, uint32_t gr
return; return;
} }
size_t i; uint32_t i;
for (i = 0; i < chat->max_idx; ++i) { for (i = 0; i < chat->max_idx; ++i) {
GroupPeer *peer = &chat->peer_list[i]; GroupPeer *peer = &chat->peer_list[i];
@ -535,9 +535,9 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
sound_notify(self, notif_error, 0, NULL); sound_notify(self, notif_error, 0, NULL);
} }
} else if (key == user_settings->key_peer_list_down) { /* Scroll peerlist up and down one position */ } else if (key == user_settings->key_peer_list_down) { /* Scroll peerlist up and down one position */
int L = y2 - CHATBOX_HEIGHT - SDBAR_OFST; const int L = y2 - CHATBOX_HEIGHT - SDBAR_OFST;
if (groupchats[self->num].side_pos < groupchats[self->num].num_peers - L) { if (groupchats[self->num].side_pos < (int64_t) groupchats[self->num].num_peers - L) {
++groupchats[self->num].side_pos; ++groupchats[self->num].side_pos;
} }
} else if (key == user_settings->key_peer_list_up) { } else if (key == user_settings->key_peer_list_up) {
@ -613,19 +613,19 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
mvwaddch(ctx->sidebar, y2 - CHATBOX_HEIGHT, 0, ACS_BTEE); mvwaddch(ctx->sidebar, y2 - CHATBOX_HEIGHT, 0, ACS_BTEE);
pthread_mutex_lock(&Winthread.lock); pthread_mutex_lock(&Winthread.lock);
int num_peers = groupchats[self->num].num_peers; uint32_t num_peers = groupchats[self->num].num_peers;
pthread_mutex_unlock(&Winthread.lock); pthread_mutex_unlock(&Winthread.lock);
wmove(ctx->sidebar, 0, 1); wmove(ctx->sidebar, 0, 1);
wattron(ctx->sidebar, A_BOLD); wattron(ctx->sidebar, A_BOLD);
wprintw(ctx->sidebar, "Peers: %d\n", num_peers); wprintw(ctx->sidebar, "Peers: %"PRIu32"\n", num_peers);
wattroff(ctx->sidebar, A_BOLD); wattroff(ctx->sidebar, A_BOLD);
mvwaddch(ctx->sidebar, 1, 0, ACS_LTEE); mvwaddch(ctx->sidebar, 1, 0, ACS_LTEE);
mvwhline(ctx->sidebar, 1, 1, ACS_HLINE, SIDEBAR_WIDTH - 1); mvwhline(ctx->sidebar, 1, 1, ACS_HLINE, SIDEBAR_WIDTH - 1);
int maxlines = y2 - SDBAR_OFST - CHATBOX_HEIGHT; int maxlines = y2 - SDBAR_OFST - CHATBOX_HEIGHT;
int i; uint32_t i;
for (i = 0; i < num_peers && i < maxlines; ++i) { for (i = 0; i < num_peers && i < maxlines; ++i) {
wmove(ctx->sidebar, i + 2, 1); wmove(ctx->sidebar, i + 2, 1);

View File

@ -46,10 +46,10 @@ typedef struct {
time_t start_time; time_t start_time;
GroupPeer *peer_list; GroupPeer *peer_list;
size_t max_idx; uint32_t max_idx;
char *name_list; char *name_list;
size_t num_peers; uint32_t num_peers;
} GroupChat; } GroupChat;