In der Zeit vom 27.05.19 16 Uhr bis zum 28.05.19 10 Uhr steht die GitLab Instanz der RWTH Aachen nicht zur Verfügung. Es findet ein Umzug des angeschlossenen Storage Systems statt, so dass in der genannten Zeit keine Repositories angelegt, gelöscht oder verändert werden können. Wir bitten um Ihr Verständnis. // In the time from 27.05.19 16 o'clock to 28.05.19 10 o'clock the GitLab instance of the RWTH Aachen is not available. The connected storage system will be moved so that no repositories can be created, deleted or changed during this time. We ask for your understanding.

Commit e22a8fbe authored by Martin Kröning's avatar Martin Kröning

Allow instancing multiple MapApps sequencially and parallelly

parent 714728eb
......@@ -37,6 +37,8 @@ public:
private:
static const std::vector<std::string> zoomLevels;
static Glib::RefPtr<Gtk::Application> app;
static std::thread thread;
void addOrReplaceVehicle(const std::string &vehicleName,
const std::string &laneName, double positionOnLane,
double speed, double remainingFuel, double red,
......@@ -46,8 +48,6 @@ private:
void onVehicleRowSelected(Gtk::ListBoxRow *row);
void refreshVehicleLabels(const DrawableVehicle &vehicle);
void refreshArea(int x, int y, int width, int height);
Glib::RefPtr<Gtk::Application> app;
std::thread thread;
MapArea mapArea;
Gtk::Window win;
Gtk::ListBox *listBox;
......
......@@ -27,10 +27,11 @@
// https://developer.gnome.org/glibmm/2.55/namespaceGlib.html#a0c450f82b9e34689e2dda2038ba7834faf2d20696a8afab425c00268d981e9897
const std::vector<std::string> MapApp::zoomLevels = {"60%", "80%", "100%"};
Glib::RefPtr<Gtk::Application> MapApp::app = Gtk::Application::create();
std::thread MapApp::thread;
MapApp::MapApp(std::string windowTitle)
: app(Gtk::Application::create()),
mapArea(junctions, roads, nameVehicleMap), listBox(nullptr),
: mapArea(junctions, roads, nameVehicleMap), listBox(nullptr),
timeLabel(nullptr), laneLabel(nullptr),
lanePositionPercentageLabel(nullptr), speedLabel(nullptr),
remainingFuelLabel(nullptr), zoomComboBoxText(nullptr) {
......@@ -70,11 +71,15 @@ MapApp::MapApp(std::string windowTitle)
viewport->add(mapArea);
mapArea.show();
thread = std::thread([this]() {
auto app = Gtk::Application::create();
app->run(win);
app->remove_window(win);
});
if (app->get_windows().empty()) {
thread = std::thread([this]() {
app = Gtk::Application::create();
app->run(win);
});
} else {
app->add_window(win);
win.show();
}
}
void MapApp::onZoomEntryActivate() {
......@@ -110,8 +115,8 @@ void MapApp::refreshArea(int x, int y, int width, int height) {
}
MapApp::~MapApp() {
win.close();
if (thread.joinable()) {
app->remove_window(win);
if (thread.joinable() && app->get_windows().empty()) {
thread.join();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment