Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated main -> gui -> source -> main.cpp #2012

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions main/gui/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,40 @@ namespace hex::init {
* @return Exit code
*/
int main(int argc, char **argv) {
using namespace hex;

// Set the main thread's name to "Main"
TaskManager::setCurrentThreadName("Main");

// Setup crash handlers right away to catch crashes as early as possible
crash::setupCrashHandlers();

// Run platform-specific initialization code
Window::initNative();

// Handle command line arguments if any have been passed
if (argc > 1) {
init::runCommandLine(argc, argv);
try {
using namespace hex;

// Set the main thread's name to "Main"
TaskManager::setCurrentThreadName("Main");

// Setup crash handlers right away to catch crashes as early as possible
crash::setupCrashHandlers();

// Run platform-specific initialization code
Window::initNative();

// Handle command line arguments if any have been passed
if (argc > 1) {
init::runCommandLine(argc, argv);
}

// Log some system information to aid debugging when users share their logs
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)
if (auto distro = ImHexApi::System::getLinuxDistro(); distro.has_value()) {
log::info("Linux distribution: {}. Version: {}", distro->name, distro->version.empty() ? "None" : distro->version);
} else {
log::warning("Linux distribution information is not available.");
}
#endif

// Run ImHex
return init::runImHex();
} catch (const std::exception &e) {
std::cerr << "Unhandled exception: " << e.what() << std::endl;
return EXIT_FAILURE;
}

// Log some system information to aid debugging when users share their logs
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();
}