Merge branch 'master' into voice

This commit is contained in:
ouwou 2023-04-29 20:31:35 -04:00
commit a5d74e0a89
5 changed files with 138 additions and 14 deletions

View File

@ -111,6 +111,12 @@ target_link_libraries(abaddon ${GTKMM_LIBRARIES})
target_link_libraries(abaddon ${CURL_LIBRARIES})
target_link_libraries(abaddon ${ZLIB_LIBRARY})
target_link_libraries(abaddon ${NLOHMANN_JSON_LIBRARIES})
target_link_libraries(abaddon ${CMAKE_DL_LIBS})
include(CheckAtomic)
if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
target_link_libraries(abaddon atomic)
endif ()
if (USE_LIBHANDY)
find_package(libhandy REQUIRED)

View File

@ -84,6 +84,7 @@ the result of fundamental issues with Discord's thread implementation.
```Shell
$ sudo dnf install g++ cmake gtkmm3.0-devel libcurl-devel sqlite-devel openssl-devel json-devel libsecret-devel libhandy-devel
```
> **Note:** On older versions of fedora you might need to install gtkmm30-devel instead of gtkmm3.0-devel. Use `dnf search gtkmm3` to see available packages.
2. `git clone https://github.com/uowuo/abaddon --recurse-submodules="subprojects" && cd abaddon`
3. `mkdir build && cd build`
4. `cmake ..`

107
cmake/CheckAtomic.cmake Normal file
View File

@ -0,0 +1,107 @@
#[[
From https://github.com/pothosware/SoapyRTLSDR/blob/master/CheckAtomic.cmake
This file is licensed as MIT:
The MIT License (MIT)
Copyright (c) 2015 Charles J. Cliffe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
]]
# - Try to find if atomics need -latomic linking
# Once done this will define
# HAVE_CXX_ATOMICS_WITHOUT_LIB - Wether atomic types work without -latomic
# HAVE_CXX_ATOMICS64_WITHOUT_LIB - Wether 64 bit atomic types work without -latomic
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckLibraryExists)
# Sometimes linking against libatomic is required for atomic ops, if
# the platform doesn't support lock-free atomics.
function(check_working_cxx_atomics varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
std::atomic<int> x;
int main() {
return std::atomic_is_lock_free(&x);
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction(check_working_cxx_atomics)
function(check_working_cxx_atomics64 varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "-std=c++11 ${CMAKE_REQUIRED_FLAGS}")
CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
return std::atomic_is_lock_free(&x);
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction(check_working_cxx_atomics64)
# Check for atomic operations.
if(MSVC)
# This isn't necessary on MSVC.
set(HAVE_CXX_ATOMICS_WITHOUT_LIB True)
else()
# First check if atomics work without the library.
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
endif()
# If not, check if the library exists, and atomics work with it.
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
if(NOT HAVE_LIBATOMIC)
message(STATUS "Host compiler appears to require libatomic, but cannot locate it.")
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB)
if (NOT HAVE_CXX_ATOMICS_WITH_LIB)
message(FATAL_ERROR "Host compiler must support std::atomic!")
endif()
endif()
# Check for 64 bit atomic operations.
if(MSVC)
set(HAVE_CXX_ATOMICS64_WITHOUT_LIB True)
else()
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
endif()
# If not, check if the library exists, and atomics work with it.
if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMIC64)
if(NOT HAVE_LIBATOMIC64)
message(STATUS "Host compiler appears to require libatomic, but cannot locate it.")
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
if (NOT HAVE_CXX_ATOMICS64_WITH_LIB)
message(FATAL_ERROR "Host compiler must support std::atomic!")
endif()
endif()

View File

@ -338,23 +338,33 @@ void ChannelList::UpdateListing() {
int sort_value = 0;
const auto folders = discord.GetUserSettings().GuildFolders;
if (folders.empty()) {
// fallback if no organization has occurred (guild_folders will be empty)
const auto guild_ids = discord.GetUserSortedGuilds();
for (const auto &guild_id : guild_ids) {
const auto guild = discord.GetGuild(guild_id);
if (!guild.has_value()) continue;
const auto guild_ids = discord.GetUserSortedGuilds();
auto iter = AddGuild(*guild, m_model->children());
if (iter) (*iter)[m_columns.m_sort] = sort_value++;
}
} else {
for (const auto &group : folders) {
auto iter = AddFolder(group);
if (iter) (*iter)[m_columns.m_sort] = sort_value++;
// user_settings.guild_folders may not contain every guild the user is in
// this seems to be the case if you organize your guilds and join a server without further organization
// so add guilds not present in guild_folders by descending id order first
std::set<Snowflake> foldered_guilds;
for (const auto &group : folders) {
foldered_guilds.insert(group.GuildIDs.begin(), group.GuildIDs.end());
}
for (auto iter = guild_ids.rbegin(); iter != guild_ids.rend(); iter++) {
if (foldered_guilds.find(*iter) == foldered_guilds.end()) {
const auto guild = discord.GetGuild(*iter);
if (!guild.has_value()) continue;
auto tree_iter = AddGuild(*guild, m_model->children());
if (tree_iter) (*tree_iter)[m_columns.m_sort] = sort_value++;
}
}
// then whatever is in folders
for (const auto &group : folders) {
auto iter = AddFolder(group);
if (iter) (*iter)[m_columns.m_sort] = sort_value++;
}
m_updating_listing = false;
AddPrivateChannels();

@ -1 +1 @@
Subproject commit 4dfe7c4c31df46e78d9a1cc0d2d6f1aef5a5d58c
Subproject commit 7384bde3725412523871f0fcf60efe5c47fbbfc6