1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2025-04-21 12:27:27 +03:00

Added Launcher class

Currently the launched application is exec-ed from deep within the menu
code. This means a lot of destructors are never run and as a result
for example file descriptors from the menu remain open in the launched
process.

This is a first step to move the launch invocation from a deep call
stack to the top level.
This commit is contained in:
Maarten ter Huurne
2014-08-07 16:48:30 +02:00
parent e32964bb50
commit 3e34124e68
5 changed files with 69 additions and 7 deletions

View File

@@ -23,6 +23,7 @@
#include "debug.h"
#include "delegate.h"
#include "gmenu2x.h"
#include "launcher.h"
#include "menu.h"
#include "selector.h"
#include "surface.h"
@@ -40,6 +41,7 @@
#include <array>
#include <fstream>
#include <sstream>
#include <utility>
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
#include <linux/vt.h>
@@ -608,17 +610,21 @@ void LinkApp::launch(const string &selectedFile) {
}
#endif
vector<string> commandLine;
if (isOpk()) {
#ifdef HAVE_LIBOPK
execlp("opkrun", "opkrun", "-m", metadata.c_str(), opkFile.c_str(),
!params.empty() ? params.c_str() : NULL,
NULL);
commandLine = { "opkrun", "-m", metadata, opkFile };
if (!params.empty()) {
commandLine.push_back(params);
}
#endif
} else {
std::string command = exec + " " + params;
execlp("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL);
commandLine = { "/bin/sh", "-c", exec + " " + params };
}
Launcher launcher(move(commandLine));
launcher.exec();
//if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
//try relaunching gmenu2x
gmenu2x->main();