summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-04-29 20:31:35 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2023-04-29 20:31:35 -0400
commita5d74e0a8907a0b617f8c64fccd14a8a8d87bb1d (patch)
treea051a457be2b1a8ce2f1f433ff801135e632d06d
parentb1326b20ff66be47b7d27259f466235ecba08287 (diff)
parent012b8329e5776a0161c194daf31a6e1c2d15cf62 (diff)
downloadabaddon-portaudio-a5d74e0a8907a0b617f8c64fccd14a8a8d87bb1d.tar.gz
abaddon-portaudio-a5d74e0a8907a0b617f8c64fccd14a8a8d87bb1d.zip
Merge branch 'master' into voice
-rw-r--r--CMakeLists.txt6
-rw-r--r--README.md1
-rw-r--r--cmake/CheckAtomic.cmake107
-rw-r--r--src/components/channels.cpp36
m---------subprojects/miniaudio0
5 files changed, 137 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c8a770a..5482a82 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/README.md b/README.md
index 372354f..051c9ff 100644
--- a/README.md
+++ b/README.md
@@ -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 ..`
diff --git a/cmake/CheckAtomic.cmake b/cmake/CheckAtomic.cmake
new file mode 100644
index 0000000..f7e79e8
--- /dev/null
+++ b/cmake/CheckAtomic.cmake
@@ -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()
+
diff --git a/src/components/channels.cpp b/src/components/channels.cpp
index e45b5c0..9cb8b09 100644
--- a/src/components/channels.cpp
+++ b/src/components/channels.cpp
@@ -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();
diff --git a/subprojects/miniaudio b/subprojects/miniaudio
-Subproject 4dfe7c4c31df46e78d9a1cc0d2d6f1aef5a5d58
+Subproject 7384bde3725412523871f0fcf60efe5c47fbbfc