1
0
mirror of synced 2024-12-12 16:01:06 +01:00
ImHex/plugins/builtin/include/content/popups/popup_crash_recovered.hpp
iTrooz 97f5175c84
impr: Better recovery from exceptions thrown in main thread (#1577)
This PR improves many things which can be seen by the commit name, but
the most important thing is the addition of a popup telling the user
when an exception is thrown


![image](https://github.com/WerWolv/ImHex/assets/42669835/db796416-9cce-4aa5-ad60-c22f05b5fc73)
2024-03-01 18:21:15 +01:00

46 lines
1.3 KiB
C++

#pragma once
#include <hex/ui/popup.hpp>
#include <hex/api/localization_manager.hpp>
#include <llvm/Demangle/Demangle.h>
#include <string>
namespace hex::plugin::builtin {
class PopupCrashRecovered : public Popup<PopupCrashRecovered> {
public:
PopupCrashRecovered(const std::exception &e)
: hex::Popup<PopupCrashRecovered>("hex.builtin.popup.crash_recover.title", false),
m_errorType(typeid(e).name()),
m_errorMessage(e.what) { }
void drawContent() override {
ImGuiExt::TextFormattedWrapped("hex.builtin.popup.crash_recover.message"_lang);
ImGuiExt::TextFormattedWrapped(hex::format("Error: {}: {}", llvm::itaniumDemangle(this->m_errorType), this->m_errorMessage));
if (ImGui::Button("hex.ui.common.okay"_lang)) {
this->close();
}
}
[[nodiscard]] ImGuiWindowFlags getFlags() const override {
return ImGuiWindowFlags_AlwaysAutoResize;
}
[[nodiscard]] ImVec2 getMinSize() const override {
return scaled({ 400, 100 });
}
[[nodiscard]] ImVec2 getMaxSize() const override {
return scaled({ 600, 300 });
}
private:
std::string m_errorType, m_errorMessage;
};
}