Simplified Emulator (main)

This commit is contained in:
t-moe
2015-04-07 15:58:14 +02:00
parent 063638103b
commit 383fc86eb4
2 changed files with 9 additions and 23 deletions

View File

@@ -1,9 +0,0 @@
extern void qt_init(int argc, char* argv[]);
extern int qt_execute();
int main(int argc, char* argv[]) {
qt_init(argc,argv);
return qt_execute();
}

View File

@@ -1,21 +1,12 @@
#include <QApplication> #include <QApplication>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
extern "C" { extern "C" {
void qt_init(int argc, char* argv[]); //Will be called at the top of the main() function //C Functions from the common folder
int qt_execute(); //Will be called after calling qt_execute
void app_init(); //Initializes the app void app_init(); //Initializes the app
void app_process(); //Processes one eventloop of the app void app_process(); //Processes one eventloop of the app
} }
QApplication* app_ptr=NULL;
void qt_init(int argc, char* argv[]) {
app_ptr = new QApplication(argc,argv);
app_init();
}
void app_loop() { void app_loop() {
while(!QApplication::closingDown()) { while(!QApplication::closingDown()) {
app_process(); app_process();
@@ -23,9 +14,13 @@ void app_loop() {
} }
} }
int qt_execute() { int main(int argc, char* argv[]) {
QApplication app(argc,argv);
app_init();
QtConcurrent::run(&app_loop); QtConcurrent::run(&app_loop);
int ret= app_ptr->exec(); return app.exec();
delete app_ptr;
return ret;
} }