forked from OpenGamers/abaddon
try and fix potential crash on ROLE_UPDATE
This commit is contained in:
@@ -159,15 +159,7 @@ GuildSettingsRolesPaneRolesListItem::GuildSettingsRolesPaneRolesListItem(const G
|
|||||||
|
|
||||||
UpdateItem(role);
|
UpdateItem(role);
|
||||||
|
|
||||||
discord.signal_role_update().connect([this, &discord](Snowflake guild_id, Snowflake role_id) {
|
discord.signal_role_update().connect(sigc::mem_fun(*this, &GuildSettingsRolesPaneRolesListItem::OnRoleUpdate));
|
||||||
if (guild_id != GuildID || role_id != RoleID) return;
|
|
||||||
const auto role = discord.GetRole(RoleID);
|
|
||||||
if (!role.has_value())
|
|
||||||
printf("nullopt??? %llu\n", (uint64_t)RoleID);
|
|
||||||
Position = role->Position;
|
|
||||||
UpdateItem(*role);
|
|
||||||
changed();
|
|
||||||
});
|
|
||||||
|
|
||||||
m_name.set_ellipsize(Pango::ELLIPSIZE_END);
|
m_name.set_ellipsize(Pango::ELLIPSIZE_END);
|
||||||
|
|
||||||
@@ -190,6 +182,15 @@ void GuildSettingsRolesPaneRolesListItem::UpdateItem(const RoleData &role) {
|
|||||||
m_name.set_text(role.Name);
|
m_name.set_text(role.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuildSettingsRolesPaneRolesListItem::OnRoleUpdate(Snowflake guild_id, Snowflake role_id) {
|
||||||
|
if (guild_id != GuildID || role_id != RoleID) return;
|
||||||
|
const auto role = Abaddon::Get().GetDiscordClient().GetRole(RoleID);
|
||||||
|
if (!role.has_value()) return;
|
||||||
|
Position = role->Position;
|
||||||
|
UpdateItem(*role);
|
||||||
|
changed();
|
||||||
|
}
|
||||||
|
|
||||||
GuildSettingsRolesPaneInfo::GuildSettingsRolesPaneInfo(Snowflake guild_id)
|
GuildSettingsRolesPaneInfo::GuildSettingsRolesPaneInfo(Snowflake guild_id)
|
||||||
: GuildID(guild_id)
|
: GuildID(guild_id)
|
||||||
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateItem(const RoleData &role);
|
void UpdateItem(const RoleData &role);
|
||||||
|
void OnRoleUpdate(Snowflake guild_id, Snowflake role_id);
|
||||||
|
|
||||||
Gtk::EventBox m_ev;
|
Gtk::EventBox m_ev;
|
||||||
Gtk::Label m_name;
|
Gtk::Label m_name;
|
||||||
|
|||||||
Reference in New Issue
Block a user