Ignore:
Timestamp:
2016-10-08T06:39:05Z (8 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
9698fc0
Parents:
58d285a
git-author:
dequis <dx@…> (08-10-16 06:32:08)
git-committer:
dequis <dx@…> (08-10-16 06:39:05)
Message:

purple: Fix handling of empty, immediate roomlist results

Two issues here:

  1. SIPE called in_progress(FALSE) immediately (which decreases refcount),

before purple_roomlist_get_list() could return (which would normally
increase refcount). The first refcount decrease steals it from the prpl,
and bad things happen.

Added an initialized flag to only do that decrease after it was
increased first. This is similar to how pidgin sets a 'dialog' attribute
after the purple_roomlist_get_list() call, and skips the unref if it's
not set.

  1. The code assumed that NULL return value means room listing not

supported. That's not quite true, so now it checks in the prpl info to
see if roomlist_get_list is defined.

Also, made purple_roomlist_data more private.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/purple.c

    r58d285a r01d56c0  
    5454};
    5555
     56struct purple_roomlist_data {
     57        GSList *chats;
     58        gint topic;
     59        gboolean initialized;
     60};
     61
     62
    5663struct im_connection *purple_ic_by_pa(PurpleAccount *pa)
    5764{
     
    771778        PurpleRoomlist *list;
    772779        struct purple_data *pd = ic->proto_data;
     780        PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
     781        PurplePluginProtocolInfo *pi = prpl->info->extra_info;
     782
     783        if (!pi || !pi->roomlist_get_list) {
     784                imcb_log(ic, "Room listing unsupported by this purple plugin");
     785                return;
     786        }
    773787
    774788        list = purple_roomlist_get_list(pd->account->gc);
    775789
    776790        if (list) {
     791                struct purple_roomlist_data *rld = list->ui_data;
     792                rld->initialized = TRUE;
     793
    777794                purple_roomlist_ref(list);
    778         } else {
    779                 imcb_log(ic, "Room listing unsupported by this purple plugin");
    780795        }
    781796}
     
    13821397        struct purple_roomlist_data *rld = list->ui_data;
    13831398
    1384         if (in_progress) {
     1399        if (in_progress || !rld) {
    13851400                return;
    13861401        }
     
    13931408
    13941409        bee_chat_list_finish(ic);
    1395         purple_roomlist_unref(list);
     1410
     1411        if (rld->initialized) {
     1412                purple_roomlist_unref(list);
     1413        }
    13961414}
    13971415
Note: See TracChangeset for help on using the changeset viewer.