Store environment variables and use on restart (#380)
- Fixes WerWolv/ImHex#373
This commit is contained in:
parent
3d32261f16
commit
b047fc0063
@ -14,7 +14,7 @@ namespace hex::init {
|
||||
|
||||
class WindowSplash {
|
||||
public:
|
||||
WindowSplash(int &argc, char **&argv);
|
||||
WindowSplash(int &argc, char **&argv, char **&envp);
|
||||
~WindowSplash();
|
||||
|
||||
bool loop();
|
||||
@ -40,4 +40,4 @@ namespace hex::init {
|
||||
std::vector<std::pair<std::string, TaskFunction>> m_tasks;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ namespace hex {
|
||||
|
||||
static int mainArgc;
|
||||
static char **mainArgv;
|
||||
static char **mainEnvp;
|
||||
|
||||
static ImFontAtlas *fontAtlas;
|
||||
static ImFontConfig fontConfig;
|
||||
@ -106,4 +107,4 @@ namespace hex {
|
||||
static std::map<std::string, std::any> sharedVariables;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace hex {
|
||||
void ImHexApi::Common::restartImHex() {
|
||||
EventManager::post<RequestCloseImHex>(false);
|
||||
std::atexit([]{
|
||||
execve(SharedData::mainArgv[0], SharedData::mainArgv, nullptr);
|
||||
execve(SharedData::mainArgv[0], SharedData::mainArgv, SharedData::mainEnvp);
|
||||
});
|
||||
}
|
||||
|
||||
@ -86,4 +86,4 @@ namespace hex {
|
||||
return Task(unlocalizedName, maxValue);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ namespace hex {
|
||||
|
||||
int SharedData::mainArgc;
|
||||
char **SharedData::mainArgv;
|
||||
char **SharedData::mainEnvp;
|
||||
|
||||
ImFontAtlas *SharedData::fontAtlas;
|
||||
ImFontConfig SharedData::fontConfig;
|
||||
@ -53,4 +54,4 @@ namespace hex {
|
||||
float SharedData::fontScale;
|
||||
|
||||
std::map<std::string, std::any> SharedData::sharedVariables;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,10 @@ using namespace std::literals::chrono_literals;
|
||||
|
||||
namespace hex::init {
|
||||
|
||||
WindowSplash::WindowSplash(int &argc, char **&argv) : m_window(nullptr) {
|
||||
WindowSplash::WindowSplash(int &argc, char **&argv, char **&envp) : m_window(nullptr) {
|
||||
SharedData::mainArgc = argc;
|
||||
SharedData::mainArgv = argv;
|
||||
SharedData::mainEnvp = envp;
|
||||
|
||||
this->initGLFW();
|
||||
this->initImGui();
|
||||
@ -239,4 +240,4 @@ namespace hex::init {
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,14 @@
|
||||
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char **argv, char **envp) {
|
||||
using namespace hex;
|
||||
|
||||
// Initialization
|
||||
{
|
||||
Window::initNative();
|
||||
|
||||
init::WindowSplash splashWindow(argc, argv);
|
||||
init::WindowSplash splashWindow(argc, argv, envp);
|
||||
|
||||
for (const auto &[name, task] : init::getInitTasks())
|
||||
splashWindow.addStartupTask(name, task);
|
||||
|
Loading…
x
Reference in New Issue
Block a user