crash fixes

This commit is contained in:
ouwou 2020-08-29 16:38:52 -04:00
parent 713ed0f927
commit 4b637b6ff2
5 changed files with 10 additions and 7 deletions

View File

@ -160,6 +160,7 @@ void ChannelList::SetListingFromGuildsInternal() {
AddPrivateChannels();
// map each category to its channels
std::unordered_map<Snowflake, std::vector<const ChannelData *>> cat_to_channels;
std::unordered_map<Snowflake, std::vector<const ChannelData *>> orphan_channels;
for (const auto &[gid, guild] : *guilds) {

View File

@ -53,7 +53,7 @@ protected:
std::queue<DiscordClient::Guilds_t> m_update_queue;
void AddPrivateChannels(); // retard moment
void SetListingFromGuildsInternal();
void AttachMenuHandler(Gtk::ListBoxRow* row);
void AttachMenuHandler(Gtk::ListBoxRow *row);
Abaddon *m_abaddon = nullptr;
};

View File

@ -65,11 +65,13 @@ std::vector<std::pair<Snowflake, GuildData>> DiscordClient::GetUserSortedGuilds(
// unpositioned_guilds now has unpositioned guilds in ascending order
for (auto it = unpositioned_guilds.rbegin(); it != unpositioned_guilds.rend(); it++)
sorted_guilds.push_back(std::make_pair(*it, m_guilds.at(*it)));
if (m_guilds.find(*it) != m_guilds.end())
sorted_guilds.push_back(std::make_pair(*it, m_guilds.at(*it)));
// now the rest go at the end in the order they are sorted
for (const auto &id : m_user_settings.GuildPositions) {
sorted_guilds.push_back(std::make_pair(id, m_guilds.at(id)));
if (m_guilds.find(id) != m_guilds.end())
sorted_guilds.push_back(std::make_pair(id, m_guilds.at(id)));
}
} else { // default sort is alphabetic
for (auto &it : m_guilds)

View File

@ -44,7 +44,7 @@ void from_json(const nlohmann::json &j, UserData &m) {
JS_O("verified", m.IsVerified);
JS_O("email", m.Email);
JS_O("flags", m.Flags);
JS_O("premium_type", m.PremiumType);
JS_ON("premium_type", m.PremiumType);
JS_O("public_flags", m.PublicFlags);
JS_O("desktop", m.IsDesktop);
JS_O("mobile", m.IsMobile);
@ -113,7 +113,7 @@ void from_json(const nlohmann::json &j, ChannelData &m) {
JS_O("guild_id", m.GuildID);
JS_O("position", m.Position);
// JS_O("permission_overwrites", m.PermissionOverwrites);
JS_O("name", m.Name);
JS_ON("name", m.Name);
JS_ON("topic", m.Topic);
JS_O("nsfw", m.IsNSFW);
JS_ON("last_message_id", m.LastMessageID);

View File

@ -101,7 +101,7 @@ struct UserData {
bool IsVerified = false; // opt
std::string Email; // opt, null
int Flags = 0; // opt
int PremiumType = 0; // opt
int PremiumType = 0; // opt, null (docs wrong)
int PublicFlags = 0; // opt
// undocumented (opt)
@ -119,7 +119,7 @@ struct ChannelData {
Snowflake GuildID; // opt
int Position = -1; // opt
// std::vector<PermissionOverwriteData> PermissionOverwrites; // opt
std::string Name; // opt
std::string Name; // opt, null (null for dm's)
std::string Topic; // opt, null
bool IsNSFW = false; // opt
Snowflake LastMessageID; // opt, null