summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-08-29 16:38:52 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-08-29 16:38:52 -0400
commit4b637b6ff20784ffde41c521be0fd7199f4a5a9b (patch)
tree2d3585f7b3c8b24d0efb99de37863881f2ab3557
parent713ed0f9271bfd9249809940cf214d600adaecab (diff)
downloadabaddon-portaudio-4b637b6ff20784ffde41c521be0fd7199f4a5a9b.tar.gz
abaddon-portaudio-4b637b6ff20784ffde41c521be0fd7199f4a5a9b.zip
crash fixes
-rw-r--r--components/channels.cpp1
-rw-r--r--components/channels.hpp2
-rw-r--r--discord/discord.cpp6
-rw-r--r--discord/objects.cpp4
-rw-r--r--discord/objects.hpp4
5 files changed, 10 insertions, 7 deletions
diff --git a/components/channels.cpp b/components/channels.cpp
index adaa11d..b3af191 100644
--- a/components/channels.cpp
+++ b/components/channels.cpp
@@ -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) {
diff --git a/components/channels.hpp b/components/channels.hpp
index b41dc63..83b242c 100644
--- a/components/channels.hpp
+++ b/components/channels.hpp
@@ -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;
};
diff --git a/discord/discord.cpp b/discord/discord.cpp
index 57327dc..7d0ca23 100644
--- a/discord/discord.cpp
+++ b/discord/discord.cpp
@@ -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)
diff --git a/discord/objects.cpp b/discord/objects.cpp
index 6350518..8de0c68 100644
--- a/discord/objects.cpp
+++ b/discord/objects.cpp
@@ -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);
diff --git a/discord/objects.hpp b/discord/objects.hpp
index db7927e..c56b766 100644
--- a/discord/objects.hpp
+++ b/discord/objects.hpp
@@ -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