mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-27 16:16:35 +03:00
fix some crashes
- crash when assuming group dms have someone other than urself - crash from lifetime error with user note update
This commit is contained in:
@@ -77,20 +77,21 @@ ChannelListRowDMChannel::ChannelListRowDMChannel(const ChannelData *data) {
|
|||||||
get_style_context()->add_class("channel-row");
|
get_style_context()->add_class("channel-row");
|
||||||
m_lbl->get_style_context()->add_class("channel-row-label");
|
m_lbl->get_style_context()->add_class("channel-row-label");
|
||||||
|
|
||||||
UserData top_recipient;
|
std::optional<UserData> top_recipient; // potentially nullopt in group dm
|
||||||
const auto recipients = data->GetDMRecipients();
|
const auto recipients = data->GetDMRecipients();
|
||||||
top_recipient = recipients[0];
|
if (recipients.size() > 0)
|
||||||
|
top_recipient = recipients[0];
|
||||||
|
|
||||||
if (data->Type == ChannelType::DM) {
|
if (data->Type == ChannelType::DM) {
|
||||||
m_status = Gtk::manage(new StatusIndicator(top_recipient.ID));
|
m_status = Gtk::manage(new StatusIndicator(top_recipient->ID));
|
||||||
m_status->set_margin_start(5);
|
m_status->set_margin_start(5);
|
||||||
|
|
||||||
if (top_recipient.HasAvatar()) {
|
if (top_recipient->HasAvatar()) {
|
||||||
m_icon = Gtk::manage(new Gtk::Image(Abaddon::Get().GetImageManager().GetPlaceholder(24)));
|
m_icon = Gtk::manage(new Gtk::Image(Abaddon::Get().GetImageManager().GetPlaceholder(24)));
|
||||||
auto cb = [this](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
|
auto cb = [this](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
|
||||||
m_icon->property_pixbuf() = pb->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
|
m_icon->property_pixbuf() = pb->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
|
||||||
};
|
};
|
||||||
Abaddon::Get().GetImageManager().LoadFromURL(top_recipient.GetAvatarURL("png", "16"), sigc::track_obj(cb, *this));
|
Abaddon::Get().GetImageManager().LoadFromURL(top_recipient->GetAvatarURL("png", "16"), sigc::track_obj(cb, *this));
|
||||||
} else {
|
} else {
|
||||||
m_icon = Gtk::manage(new Gtk::Image(Abaddon::Get().GetImageManager().GetPlaceholder(24)));
|
m_icon = Gtk::manage(new Gtk::Image(Abaddon::Get().GetImageManager().GetPlaceholder(24)));
|
||||||
}
|
}
|
||||||
@@ -98,7 +99,7 @@ ChannelListRowDMChannel::ChannelListRowDMChannel(const ChannelData *data) {
|
|||||||
|
|
||||||
auto buf = m_lbl->get_buffer();
|
auto buf = m_lbl->get_buffer();
|
||||||
if (data->Type == ChannelType::DM)
|
if (data->Type == ChannelType::DM)
|
||||||
buf->set_text(top_recipient.Username);
|
buf->set_text(top_recipient->Username);
|
||||||
else if (data->Type == ChannelType::GROUP_DM)
|
else if (data->Type == ChannelType::GROUP_DM)
|
||||||
buf->set_text(std::to_string(recipients.size()) + " users");
|
buf->set_text(std::to_string(recipients.size()) + " users");
|
||||||
Abaddon::Get().GetEmojis().ReplaceEmojis(buf, ChannelEmojiSize);
|
Abaddon::Get().GetEmojis().ReplaceEmojis(buf, ChannelEmojiSize);
|
||||||
|
|||||||
@@ -176,10 +176,11 @@ ProfileUserInfoPane::ProfileUserInfoPane(Snowflake ID)
|
|||||||
});
|
});
|
||||||
|
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||||
discord.signal_note_update().connect([this](Snowflake id, std::string note) {
|
auto note_update_cb = [this](Snowflake id, std::string note) {
|
||||||
if (id == UserID)
|
if (id == UserID)
|
||||||
m_note.SetNote(note);
|
m_note.SetNote(note);
|
||||||
});
|
};
|
||||||
|
discord.signal_note_update().connect(sigc::track_obj(note_update_cb, m_note));
|
||||||
|
|
||||||
auto fetch_note_cb = [this](const std::string ¬e) {
|
auto fetch_note_cb = [this](const std::string ¬e) {
|
||||||
m_note.SetNote(note);
|
m_note.SetNote(note);
|
||||||
|
|||||||
Reference in New Issue
Block a user