diff --git a/src/chat_gui/file_selector.cpp b/src/chat_gui/file_selector.cpp index e33b52e3..e512a16a 100644 --- a/src/chat_gui/file_selector.cpp +++ b/src/chat_gui/file_selector.cpp @@ -111,56 +111,60 @@ void FileSelector::render(void) { } } - // do sorting here - // TODO: cache the result (lol) - if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); sorts_specs != nullptr && sorts_specs->SpecsCount >= 1) { - switch (static_cast(sorts_specs->Specs->ColumnUserID)) { - break; case SortID::name: - if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) { - std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { - return a.path() < b.path(); - }); - std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { - return a.path().filename() < b.path().filename(); - }); - } else { - std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { - return a.path() > b.path(); - }); - std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { - return a.path().filename() > b.path().filename(); - }); - } - break; case SortID::size: - if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) { - // TODO: sort dirs? - std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { - return a.file_size() < b.file_size(); - }); - } else { - // TODO: sort dirs? - std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { - return a.file_size() > b.file_size(); - }); - } - break; case SortID::date: - if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) { - std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { - return a.last_write_time() < b.last_write_time(); - }); - std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { - return a.last_write_time() < b.last_write_time(); - }); - } else { - std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { - return a.last_write_time() > b.last_write_time(); - }); - std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { - return a.last_write_time() > b.last_write_time(); - }); - } - break; default: ; + try { + // do sorting here + // TODO: cache the result (lol) + if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); sorts_specs != nullptr && sorts_specs->SpecsCount >= 1) { + switch (static_cast(sorts_specs->Specs->ColumnUserID)) { + break; case SortID::name: + if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) { + std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { + return a.path() < b.path(); + }); + std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { + return a.path().filename() < b.path().filename(); + }); + } else { + std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { + return a.path() > b.path(); + }); + std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { + return a.path().filename() > b.path().filename(); + }); + } + break; case SortID::size: + if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) { + // TODO: sort dirs? + std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { + return a.file_size() < b.file_size(); + }); + } else { + // TODO: sort dirs? + std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { + return a.file_size() > b.file_size(); + }); + } + break; case SortID::date: + if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) { + std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { + return a.last_write_time() < b.last_write_time(); + }); + std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { + return a.last_write_time() < b.last_write_time(); + }); + } else { + std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool { + return a.last_write_time() > b.last_write_time(); + }); + std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool { + return a.last_write_time() > b.last_write_time(); + }); + } + break; default: ; + } } + } catch (...) { + // we likely saw a file disapear } for (auto const& dir_entry : dirs) { diff --git a/src/frame_streams/stream_manager.cpp b/src/frame_streams/stream_manager.cpp index 81969f64..a39f9e8e 100644 --- a/src/frame_streams/stream_manager.cpp +++ b/src/frame_streams/stream_manager.cpp @@ -168,7 +168,7 @@ bool StreamManager::onEvent(const ObjectStore::Events::ObjectConstruct& e) { auto it_d_src = _default_sources.find(e.e.get().frame_type_name); if (it_d_src != _default_sources.cend()) { // TODO: threaded - connect(e.e, it_d_src->second); + connect(it_d_src->second, e.e); } } } diff --git a/src/stream_manager_ui.cpp b/src/stream_manager_ui.cpp index eb7e01bd..48166c25 100644 --- a/src/stream_manager_ui.cpp +++ b/src/stream_manager_ui.cpp @@ -126,7 +126,7 @@ void StreamManagerUI::render(void) { if (_os.registry().all_of(oc)) { ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, ImGui::GetColorU32(ImVec4{0.6f, 0.f, 0.6f, 0.25f})); - } else if (_os.registry().all_of(oc)) { + } else if (_os.registry().all_of(oc)) { ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, ImGui::GetColorU32(ImVec4{0.6f, 0.6f, 0.f, 0.25f})); }