mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-04 11:33:27 +03:00
try and fix potential crash on ROLE_UPDATE
This commit is contained in:
@@ -159,15 +159,7 @@ GuildSettingsRolesPaneRolesListItem::GuildSettingsRolesPaneRolesListItem(const G
|
||||
|
||||
UpdateItem(role);
|
||||
|
||||
discord.signal_role_update().connect([this, &discord](Snowflake guild_id, Snowflake role_id) {
|
||||
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();
|
||||
});
|
||||
discord.signal_role_update().connect(sigc::mem_fun(*this, &GuildSettingsRolesPaneRolesListItem::OnRoleUpdate));
|
||||
|
||||
m_name.set_ellipsize(Pango::ELLIPSIZE_END);
|
||||
|
||||
@@ -190,6 +182,15 @@ void GuildSettingsRolesPaneRolesListItem::UpdateItem(const RoleData &role) {
|
||||
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)
|
||||
: GuildID(guild_id)
|
||||
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
void UpdateItem(const RoleData &role);
|
||||
void OnRoleUpdate(Snowflake guild_id, Snowflake role_id);
|
||||
|
||||
Gtk::EventBox m_ev;
|
||||
Gtk::Label m_name;
|
||||
|
||||
Reference in New Issue
Block a user