Compare commits

..

6 Commits

Author SHA1 Message Date
WerWolv
72d5707d33 build: Bumped version to 1.34.0 2024-06-03 22:22:33 +02:00
WerWolv
a491b85737 build: Added simple script to generate release notes 2024-06-03 22:14:08 +02:00
Alexander Wilms
d9d85cbfcc impr: Added keywords to .desktop file (#1732)
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->
This adds a list of strings which may be used in addition to other
metadata to describe the application. This can be useful e.g. to
facilitate searching through entries.

Reference:
https://webcache.googleusercontent.com/search?q=cache:https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

(The original site is currently down due to a Gitlab upgrade)

These keywords are used by
[Flathub](https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/#launchable),
[KDE
Discover](https://discuss.kde.org/t/does-kde-discover-parse-the-desktop-file-for-categories-and-keywords/7041)
and [Gnome
Software](https://blogs.gnome.org/hughsie/2016/01/07/the-importance-of-keywords-for-the-software-center/).

### Implementation description
<!-- Explain what you did to correct the problem -->
Add a `Keywords` entry to the .desktop file.

### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->

Here's how the tags are displayed for TeXstudio on its Flathub page: 

![image](https://github.com/WerWolv/ImHex/assets/3226457/35e00272-433e-46cd-9a9e-c42913aefe3f)


### Additional things
<!-- Anything else you would like to say -->
2024-06-03 19:44:05 +02:00
iTrooz
283fe46230 git: Replace Ubuntu 23.04 with 24.04 LTS (#1731) 2024-06-03 17:25:50 +02:00
iTrooz
2c00aa5def fix: Do not use custom repo gcc 13 for Ubuntu because it doesn't run on vanilla Ubuntu (#1730) 2024-06-03 08:06:49 +00:00
iTrooz
984438e98d feat: show Linux distribution information on startup (#1729) 2024-06-03 10:02:29 +02:00
23 changed files with 210 additions and 280 deletions

View File

@@ -354,7 +354,7 @@ jobs:
matrix:
include:
- release_num: 22.04
- release_num: 23.04
- release_num: 24.04
name: 🐧 Ubuntu ${{ matrix.release_num }}
runs-on: ubuntu-latest
@@ -384,11 +384,6 @@ jobs:
apt update
bash dist/get_deps_debian.sh
apt install software-properties-common -y
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt update
apt install -y gcc-13 g++-13
- name: ⬇️ Install .NET
uses: actions/setup-dotnet@v4
with:
@@ -402,7 +397,7 @@ jobs:
git config --global --add safe.directory '*'
mkdir -p build
cd build
CC=gcc-13 CXX=g++-13 cmake -G "Ninja" \
CC=gcc-12 CXX=g++-12 cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \

View File

@@ -69,7 +69,6 @@ addBundledLibraries()
add_subdirectory(lib/libimhex)
add_subdirectory(main)
addPluginDirectories()
add_subdirectory(lib/trace)
# Add unit tests
if (IMHEX_ENABLE_UNIT_TESTS)

View File

@@ -1 +1 @@
1.33.0
1.34.0

View File

@@ -543,9 +543,13 @@ macro(setupDebugCompressionFlag)
if (NOT DEBUG_COMPRESSION_FLAG) # Cache variable
if (ZSTD_AVAILABLE_COMPILER AND ZSTD_AVAILABLE_LINKER)
message("Using Zstd compression for debug info because both compiler and linker support it")
set(DEBUG_COMPRESSION_FLAG "-gz=zstd" CACHE STRING "Cache to use for debug info compression")
elseif (COMPRESS_AVAILABLE_COMPILER AND COMPRESS_AVAILABLE_LINKER)
message("Using default compression for debug info because both compiler and linker support it")
set(DEBUG_COMPRESSION_FLAG "-gz" CACHE STRING "Cache to use for debug info compression")
else()
message("No compression available for debug info")
endif()
endif()
@@ -730,6 +734,30 @@ macro(addBundledLibraries)
find_package(mbedTLS 3.4.0 REQUIRED)
find_package(Magic 5.39 REQUIRED)
if (NOT IMHEX_DISABLE_STACKTRACE)
if (WIN32)
message(STATUS "StackWalk enabled!")
set(LIBBACKTRACE_LIBRARIES DbgHelp.lib)
else ()
find_package(Backtrace)
if (${Backtrace_FOUND})
message(STATUS "Backtrace enabled! Header: ${Backtrace_HEADER}")
if (Backtrace_HEADER STREQUAL "backtrace.h")
set(LIBBACKTRACE_LIBRARIES ${Backtrace_LIBRARY})
set(LIBBACKTRACE_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
add_compile_definitions(BACKTRACE_HEADER=<${Backtrace_HEADER}>)
add_compile_definitions(HEX_HAS_BACKTRACE)
elseif (Backtrace_HEADER STREQUAL "execinfo.h")
set(LIBBACKTRACE_LIBRARIES ${Backtrace_LIBRARY})
set(LIBBACKTRACE_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
add_compile_definitions(BACKTRACE_HEADER=<${Backtrace_HEADER}>)
add_compile_definitions(HEX_HAS_EXECINFO)
endif()
endif()
endif()
endif()
endmacro()
function(enableUnityBuild TARGET)

View File

@@ -37,7 +37,7 @@ macro(add_imhex_plugin)
# Add include directories and link libraries
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv tracing)
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)

48
dist/gen_release_notes.py vendored Normal file
View File

@@ -0,0 +1,48 @@
import subprocess
import sys
def get_commits(branch: str, start_tag: str, end_tag: str) -> list[str]:
try:
commits_raw = subprocess.check_output([ "git", "--no-pager", "log", branch, "--no-color", "--pretty=oneline", "--abbrev-commit", f"{start_tag}..{end_tag}"], stderr=subprocess.DEVNULL).decode("UTF-8").split("\n")
except:
return []
commits = []
for line in commits_raw:
commits.append(line[9:])
return commits
def main(args: list) -> int:
if len(args) != 2:
print(f"Usage: {args[0]} prev_minor")
return 1
last_minor_version = f"v1.{args[1]}"
master_commits = get_commits("master", f"{last_minor_version}.0", "master")
for i in range(1, 100):
branch_commits = get_commits(f"releases/{last_minor_version}.X", f"{last_minor_version}.0", f"{last_minor_version}.{i}")
if len(branch_commits) == 0:
break
master_commits = [commit for commit in master_commits if commit not in branch_commits]
sorted_commits = {}
for commit in master_commits:
category, commit_name = commit.split(":", 1)
if category not in sorted_commits:
sorted_commits[category] = []
sorted_commits[category].append(commit_name)
for category in sorted_commits:
print(f"## {category}\n")
for commit in sorted_commits[category]:
print(f"- {commit}")
print(f"\n")
if __name__ == "__main__":
exit(main(sys.argv))

1
dist/imhex.desktop vendored
View File

@@ -8,3 +8,4 @@ Type=Application
StartupNotify=true
Categories=Development;IDE;
StartupWMClass=imhex
Keywords=static-analysis;reverse-engineering;disassembler;disassembly;hacking;forensics;hex-editor;cybersecurity;security;binary-analysis;

View File

@@ -142,7 +142,7 @@ if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
precompileHeaders(libimhex "${CMAKE_CURRENT_SOURCE_DIR}/include")
endif()
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES} ${LUNASVG_LIBRARIES} tracing)
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES} ${LUNASVG_LIBRARIES})
set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)

View File

@@ -597,6 +597,16 @@ namespace hex {
*/
std::string getArchitecture();
struct LinuxDistro {
std::string name;
std::string version;
};
/**
* @brief Gets information related to the Linux distribution, if running on Linux
*/
std::optional<LinuxDistro> getLinuxDistro();
/**
* @brief Gets the current ImHex version
* @return ImHex version

View File

@@ -15,6 +15,8 @@
#include <imgui.h>
#include <imgui_internal.h>
#include <set>
#include <fstream>
#include <algorithm>
#include <GLFW/glfw3.h>
#if defined(OS_WINDOWS)
@@ -742,6 +744,25 @@ namespace hex {
#endif
}
std::optional<LinuxDistro> getLinuxDistro() {
std::ifstream file("/etc/os-release");
std::string name;
std::string version;
std::string line;
while (std::getline(file, line)) {
if (line.find("PRETTY_NAME=") != std::string::npos) {
name = line.substr(line.find("=") + 1);
name.erase(std::remove(name.begin(), name.end(), '\"'), name.end());
} else if (line.find("VERSION_ID=") != std::string::npos) {
version = line.substr(line.find("=") + 1);
version.erase(std::remove(version.begin(), version.end(), '\"'), version.end());
}
}
return {{name, version}};
}
std::string getImHexVersion(bool withBuildType) {
#if defined IMHEX_VERSION
if (withBuildType) {

View File

@@ -1,64 +0,0 @@
project(tracing)
option(IMHEX_TRACE_EXCEPTIONS "Hook thrown exceptions to display a stack trace when possible" ON)
option(IMHEX_INSTRUMENT_FUNCTIONS "Hook all function entries and exits to profile things in Tracy" ON)
add_library(tracing OBJECT
source/stacktrace.cpp
source/exceptions.cpp
)
target_include_directories(tracing PUBLIC include)
target_link_libraries(tracing PRIVATE stdc++exp)
if (NOT IMHEX_DISABLE_STACKTRACE)
if (WIN32)
message(STATUS "StackWalk enabled!")
target_link_libraries(tracing PRIVATE DbgHelp.lib)
else ()
find_package(Backtrace)
if (${Backtrace_FOUND})
message(STATUS "Backtrace enabled! Header: ${Backtrace_HEADER}")
if (Backtrace_HEADER STREQUAL "backtrace.h")
target_link_libraries(tracing PRIVATE ${Backtrace_LIBRARY})
target_include_directories(tracing PRIVATE ${Backtrace_INCLUDE_DIR})
target_compile_definitions(tracing PRIVATE BACKTRACE_HEADER=<${Backtrace_HEADER}>)
target_compile_definitions(tracing PRIVATE HEX_HAS_BACKTRACE)
elseif (Backtrace_HEADER STREQUAL "execinfo.h")
target_link_libraries(tracing PRIVATE ${Backtrace_LIBRARY})
target_include_directories(tracing PRIVATE ${Backtrace_INCLUDE_DIR})
target_compile_definitions(tracing PRIVATE BACKTRACE_HEADER=<${Backtrace_HEADER}>)
target_compile_definitions(tracing PRIVATE HEX_HAS_EXECINFO)
endif()
endif()
endif()
target_link_libraries(tracing PRIVATE LLVMDemangle)
endif()
if (IMHEX_TRACE_EXCEPTIONS)
target_link_options(tracing PUBLIC "-Wl,--wrap=__cxa_throw")
endif()
if (IMHEX_INSTRUMENT_FUNCTIONS)
target_sources(tracing PUBLIC
source/instrumentation.cpp
)
set(TRACY_ON_DEMAND ON CACHE INTERNAL "TRACY_ON_DEMAND")
set(TRACY_DELAYED_INIT ON CACHE INTERNAL "TRACY_DELAYED_INIT")
set(TRACY_ONLY_LOCALHOST ON CACHE INTERNAL "TRACY_ONLY_LOCALHOST")
set(TRACY_NO_FRAME_IMAGE ON CACHE INTERNAL "TRACY_NO_FRAME_IMAGE")
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "BUILD_SHARED_LIBS")
FetchContent_Declare(
tracy
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(tracy)
target_compile_options(TracyClient PRIVATE "-Wno-error")
target_link_libraries(tracing PUBLIC TracyClient)
target_compile_definitions(tracing PUBLIC IMHEX_USE_INSTRUMENTATION=1)
endif()

View File

@@ -1,11 +0,0 @@
#pragma once
#include <hex/trace/stacktrace.hpp>
#include <optional>
namespace hex::trace {
std::optional<StackTrace> getLastExceptionStackTrace();
}

View File

@@ -1,18 +0,0 @@
#pragma once
#if defined(IMHEX_USE_INSTRUMENTATION)
#include <tracy/Tracy.hpp>
#define IMHEX_TRACE_SCOPE ZoneScoped
#define IMHEX_TRACE_SCOPE_NAME(name) ZoneScoped; ZoneName(name, strlen(name))
#define IMHEX_START_FRAME_MARK FrameMarkStart("Frame")
#define IMHEX_END_FRAME_MARK FrameMarkEnd("Frame")
#define IMHEX_TRACE_MESSAGE(message) TracyMessage(message, strlen(message))
#else
#define IMHEX_TRACE_SCOPE_NAME(name)
#define IMHEX_END_FRAME_MARK
#endif

View File

@@ -1,27 +0,0 @@
#include <hex/trace/exceptions.hpp>
namespace hex::trace {
static std::optional<StackTrace> s_lastExceptionStackTrace;
std::optional<StackTrace> getLastExceptionStackTrace() {
if (!s_lastExceptionStackTrace.has_value())
return std::nullopt;
auto result = s_lastExceptionStackTrace.value();
s_lastExceptionStackTrace.reset();
return result;
}
}
extern "C" {
[[noreturn]] void __real___cxa_throw(void* thrownException, void* type, void (*destructor)(void*));
[[noreturn]] void __wrap___cxa_throw(void* thrownException, void* type, void (*destructor)(void*)) {
hex::trace::s_lastExceptionStackTrace = hex::trace::getStackTrace();
__real___cxa_throw(thrownException, type, destructor);
}
}

View File

@@ -1 +0,0 @@
#include <hex/trace/instrumentation.hpp>

View File

@@ -3,6 +3,7 @@ project(main)
add_executable(main ${APPLICATION_TYPE}
source/main.cpp
source/crash_handlers.cpp
source/stacktrace.cpp
source/window/window.cpp
source/window/win_window.cpp
@@ -57,7 +58,7 @@ set_target_properties(main PROPERTIES
target_compile_definitions(main PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
target_link_libraries(main PRIVATE libromfs-imhex libimhex libwolv ${LIBBACKTRACE_LIBRARIES} LLVMDemangle tracing)
target_link_libraries(main PRIVATE libromfs-imhex libimhex libwolv ${LIBBACKTRACE_LIBRARIES} LLVMDemangle)
if (WIN32)
target_link_libraries(main PRIVATE usp10 wsock32 ws2_32 Dwmapi.lib)
else ()
@@ -68,4 +69,4 @@ precompileHeaders(main ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (APPLE)
add_compile_definitions(GL_SILENCE_DEPRECATION)
endif ()
endif ()

View File

@@ -1,20 +1,20 @@
#pragma once
#include <cstdint>
#include <hex.hpp>
#include <string>
#include <vector>
namespace hex::trace {
namespace hex::stacktrace {
struct StackFrame {
std::string file;
std::string function;
std::uint32_t line;
u32 line;
};
using StackTrace = std::vector<StackFrame>;
void initialize();
StackTrace getStackTrace();
std::vector<StackFrame> getStackTrace();
}

View File

@@ -1,7 +1,5 @@
#pragma once
#include <hex.hpp>
#include <filesystem>
#include <memory>
#include <string>
@@ -36,7 +34,6 @@ namespace hex {
void beginNativeWindowFrame();
void endNativeWindowFrame();
void drawTitleBar();
void drawView(const std::string &name, const std::unique_ptr<View> &view);
void frameBegin();
void frame();

View File

@@ -13,7 +13,7 @@
#include <nlohmann/json.hpp>
#include <hex/trace/stacktrace.hpp>
#include <stacktrace.hpp>
#include <llvm/Demangle/Demangle.h>
#include <csignal>
@@ -63,7 +63,7 @@ namespace hex::crash {
}
static void printStackTrace() {
for (const auto &stackFrame : trace::getStackTrace()) {
for (const auto &stackFrame : stacktrace::getStackTrace()) {
if (stackFrame.line == 0)
log::fatal(" ({}) | {}", stackFrame.file, stackFrame.function);
else
@@ -153,7 +153,7 @@ namespace hex::crash {
// Setup functions to handle signals, uncaught exception, or similar stuff that will crash ImHex
void setupCrashHandlers() {
trace::initialize();
stacktrace::initialize();
// Register signal handlers
{

View File

@@ -43,6 +43,11 @@ int main(int argc, char **argv) {
log::info("Welcome to ImHex {}!", ImHexApi::System::getImHexVersion());
log::info("Compiled using commit {}@{}", ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash());
log::info("Running on {} {} ({})", ImHexApi::System::getOSName(), ImHexApi::System::getOSVersion(), ImHexApi::System::getArchitecture());
#if defined(OS_LINUX)
auto distro = ImHexApi::System::getLinuxDistro().value();
log::info("Linux distribution: {}. Version: {}", distro.name, distro.version == "" ? "None" : distro.version);
#endif
// Run ImHex
return init::runImHex();

View File

@@ -1,6 +1,7 @@
#include <iostream>
#include <hex/trace/stacktrace.hpp>
#include <stacktrace.hpp>
#include <hex/helpers/fmt.hpp>
#include <array>
#include <llvm/Demangle/Demangle.h>
namespace {
@@ -17,48 +18,19 @@ namespace {
}
#if __has_include(<stacktrace>)
#include <stacktrace>
namespace hex::trace {
void initialize() {
}
StackTrace getStackTrace() {
StackTrace result;
auto stackTrace = std::stacktrace::current();
for (const auto &entry : stackTrace) {
if (entry.source_line() == 0 && entry.source_file().empty())
result.emplace_back("", "??", 0);
else
result.emplace_back(entry.source_file(), entry.description(), entry.source_line());
}
return result;
}
}
#elif defined(OS_WINDOWS)
#if defined(OS_WINDOWS)
#include <windows.h>
#include <dbghelp.h>
#include <array>
namespace hex::trace {
namespace hex::stacktrace {
void initialize() {
}
StackTrace getStackTrace() {
StackTrace stackTrace;
std::vector<StackFrame> getStackTrace() {
std::vector<StackFrame> stackTrace;
HANDLE process = GetCurrentProcess();
HANDLE thread = GetCurrentThread();
@@ -112,7 +84,7 @@ namespace {
DWORD displacementLine = 0;
std::uint32_t lineNumber = 0;
u32 lineNumber = 0;
const char *fileName;
if (SymGetLineFromAddr64(process, stackFrame.AddrPC.Offset, &displacementLine, &line) == TRUE) {
lineNumber = line.LineNumber;
@@ -138,18 +110,17 @@ namespace {
#if __has_include(BACKTRACE_HEADER)
#include BACKTRACE_HEADER
#include <filesystem>
#include <hex/helpers/utils.hpp>
#include <dlfcn.h>
#include <array>
namespace hex::trace {
namespace hex::stacktrace {
void initialize() {
}
StackTrace getStackTrace() {
StackTrace result;
std::vector<StackFrame> getStackTrace() {
static std::vector<StackFrame> result;
std::array<void*, 128> addresses = {};
const size_t count = backtrace(addresses.data(), addresses.size());
@@ -158,7 +129,7 @@ namespace {
for (size_t i = 0; i < count; i += 1) {
dladdr(addresses[i], &info);
auto fileName = info.dli_fname != nullptr ? std::filesystem::path(info.dli_fname).filename().string() : "??";
auto fileName = info.dli_fname != nullptr ? std::fs::path(info.dli_fname).filename().string() : "??";
auto demangledName = info.dli_sname != nullptr ? tryDemangle(info.dli_sname) : "??";
result.push_back(StackFrame { std::move(fileName), std::move(demangledName), 0 });
@@ -176,10 +147,10 @@ namespace {
#if __has_include(BACKTRACE_HEADER)
#include BACKTRACE_HEADER
#include <hex/helpers/logger.hpp>
#include <hex/helpers/utils.hpp>
#include <wolv/io/fs.hpp>
namespace hex::trace {
namespace hex::stacktrace {
static struct backtrace_state *s_backtraceState;
@@ -187,13 +158,14 @@ namespace {
void initialize() {
if (auto executablePath = wolv::io::fs::getExecutablePath(); executablePath.has_value()) {
static std::string path = executablePath->string();
s_backtraceState = backtrace_create_state(path.c_str(), 1, [](void *, const char *, int) { }, nullptr);
s_backtraceState = backtrace_create_state(path.c_str(), 1, [](void *, const char *msg, int) { log::error("{}", msg); }, nullptr);
}
}
StackTrace getStackTrace() {
StackTrace result;
std::vector<StackFrame> getStackTrace() {
static std::vector<StackFrame> result;
result.clear();
if (s_backtraceState != nullptr) {
backtrace_full(s_backtraceState, 0, [](void *, uintptr_t, const char *fileName, int lineNumber, const char *function) -> int {
if (fileName == nullptr)
@@ -201,7 +173,7 @@ namespace {
if (function == nullptr)
function = "??";
result.push_back(StackFrame { std::filesystem::path(fileName).filename().string(), tryDemangle(function), std::uint32_t(lineNumber) });
result.push_back(StackFrame { std::fs::path(fileName).filename().string(), tryDemangle(function), u32(lineNumber) });
return 0;
}, nullptr, nullptr);
@@ -217,10 +189,10 @@ namespace {
#else
namespace hex::trace {
namespace hex::stacktrace {
void initialize() { }
StackTrace getStackTrace() { return { StackFrame { "??", "Stacktrace collecting not available!", 0 } }; }
std::vector<StackFrame> getStackTrace() { return { StackFrame { "??", "Stacktrace collecting not available!", 0 } }; }
}

View File

@@ -17,8 +17,6 @@
#include <hex/ui/view.hpp>
#include <hex/ui/popup.hpp>
#include <hex/trace/instrumentation.hpp>
#include <chrono>
#include <csignal>
@@ -238,9 +236,7 @@ namespace hex {
glfwSetWindowSizeLimits(m_window, lastWindowSize.x, lastWindowSize.y, lastWindowSize.x, lastWindowSize.y);
}
IMHEX_START_FRAME_MARK;
this->fullFrame();
IMHEX_END_FRAME_MARK;
ImHexApi::System::impl::setLastFrameTime(glfwGetTime() - m_lastStartFrameTime);
@@ -292,8 +288,6 @@ namespace hex {
}
void Window::frameBegin() {
IMHEX_TRACE_SCOPE;
// Start new ImGui Frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
@@ -552,80 +546,72 @@ namespace hex {
TaskManager::runDeferredCalls();
}
void Window::drawView(const std::string &name, const std::unique_ptr<View> &view) {
IMHEX_TRACE_SCOPE_NAME(name.c_str());
// Draw always visible views
view->drawAlwaysVisibleContent();
// Skip views that shouldn't be processed currently
if (!view->shouldProcess())
return;
const auto openViewCount = std::ranges::count_if(ContentRegistry::Views::impl::getEntries(), [](const auto &entry) {
const auto &[unlocalizedName, openView] = entry;
return openView->hasViewMenuItemEntry() && openView->shouldProcess();
});
ImGuiWindowClass windowClass = {};
windowClass.DockNodeFlagsOverrideSet |= ImGuiDockNodeFlags_NoCloseButton;
if (openViewCount <= 1 || LayoutManager::isLayoutLocked())
windowClass.DockNodeFlagsOverrideSet |= ImGuiDockNodeFlags_NoTabBar;
ImGui::SetNextWindowClass(&windowClass);
auto window = ImGui::FindWindowByName(view->getName().c_str());
if (window != nullptr && window->DockNode == nullptr)
ImGui::SetNextWindowBgAlpha(1.0F);
// Draw view
view->draw();
view->trackViewOpenState();
if (view->getWindowOpenState()) {
bool hasWindow = window != nullptr;
bool focused = false;
// Get the currently focused view
if (hasWindow && (window->Flags & ImGuiWindowFlags_Popup) != ImGuiWindowFlags_Popup) {
auto windowName = View::toWindowName(name);
ImGui::Begin(windowName.c_str());
// Detect if the window is focused
focused = ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy);
// Dock the window if it's not already docked
if (view->didWindowJustOpen() && !ImGui::IsWindowDocked()) {
ImGui::DockBuilderDockWindow(windowName.c_str(), ImHexApi::System::getMainDockSpaceId());
EventViewOpened::post(view.get());
}
ImGui::End();
}
// Pass on currently pressed keys to the shortcut handler
auto &io = ImGui::GetIO();
for (const auto &key : m_pressedKeys) {
ShortcutManager::process(view.get(), io.KeyCtrl, io.KeyAlt, io.KeyShift, io.KeySuper, focused, key);
}
}
}
void Window::frame() {
IMHEX_TRACE_SCOPE;
auto &io = ImGui::GetIO();
// Loop through all views and draw them
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
ImGui::GetCurrentContext()->NextWindowData.ClearFlags();
drawView(name, view);
// Draw always visible views
view->drawAlwaysVisibleContent();
// Skip views that shouldn't be processed currently
if (!view->shouldProcess())
continue;
const auto openViewCount = std::ranges::count_if(ContentRegistry::Views::impl::getEntries(), [](const auto &entry) {
const auto &[unlocalizedName, openView] = entry;
return openView->hasViewMenuItemEntry() && openView->shouldProcess();
});
ImGuiWindowClass windowClass = {};
windowClass.DockNodeFlagsOverrideSet |= ImGuiDockNodeFlags_NoCloseButton;
if (openViewCount <= 1 || LayoutManager::isLayoutLocked())
windowClass.DockNodeFlagsOverrideSet |= ImGuiDockNodeFlags_NoTabBar;
ImGui::SetNextWindowClass(&windowClass);
auto window = ImGui::FindWindowByName(view->getName().c_str());
if (window != nullptr && window->DockNode == nullptr)
ImGui::SetNextWindowBgAlpha(1.0F);
// Draw view
view->draw();
view->trackViewOpenState();
if (view->getWindowOpenState()) {
bool hasWindow = window != nullptr;
bool focused = false;
// Get the currently focused view
if (hasWindow && (window->Flags & ImGuiWindowFlags_Popup) != ImGuiWindowFlags_Popup) {
auto windowName = View::toWindowName(name);
ImGui::Begin(windowName.c_str());
// Detect if the window is focused
focused = ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy);
// Dock the window if it's not already docked
if (view->didWindowJustOpen() && !ImGui::IsWindowDocked()) {
ImGui::DockBuilderDockWindow(windowName.c_str(), ImHexApi::System::getMainDockSpaceId());
EventViewOpened::post(view.get());
}
ImGui::End();
}
// Pass on currently pressed keys to the shortcut handler
for (const auto &key : m_pressedKeys) {
ShortcutManager::process(view.get(), io.KeyCtrl, io.KeyAlt, io.KeyShift, io.KeySuper, focused, key);
}
}
}
// Handle global shortcuts
auto &io = ImGui::GetIO();
for (const auto &key : m_pressedKeys) {
ShortcutManager::processGlobals(io.KeyCtrl, io.KeyAlt, io.KeyShift, io.KeySuper, key);
}
@@ -634,8 +620,6 @@ namespace hex {
}
void Window::frameEnd() {
IMHEX_TRACE_SCOPE;
EventFrameEnd::post();
TutorialManager::drawTutorial();
@@ -754,7 +738,6 @@ namespace hex {
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
if (initialWindowProperties.has_value()) {
glfwWindowHint(GLFW_MAXIMIZED, initialWindowProperties->maximized);

View File

@@ -6,8 +6,6 @@
#include <hex/api/achievement_manager.hpp>
#include <hex/api/workspace_manager.hpp>
#include <hex/trace/exceptions.hpp>
#include <hex/providers/provider.hpp>
#include <hex/ui/view.hpp>
@@ -55,13 +53,6 @@ namespace hex::plugin::builtin {
static bool imhexClosing = false;
EventCrashRecovered::subscribe([](const std::exception &e) {
PopupCrashRecovered::open(e);
auto stackTrace = hex::trace::getLastExceptionStackTrace();
if (stackTrace.has_value()) {
for (const auto &entry : *stackTrace) {
hex::log::fatal(" {} at {}:{}", entry.function, entry.file, entry.line);
}
}
});
EventWindowClosing::subscribe([](GLFWwindow *window) {