mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
eliminated DaemonQTImpl singleton
This commit is contained in:
parent
f76c04b7a6
commit
4fc80fd366
3 changed files with 174 additions and 89 deletions
57
i2pd.cpp
57
i2pd.cpp
|
@ -1,46 +1,23 @@
|
|||
#ifndef ANDROID
|
||||
# include <stdlib.h>
|
||||
# include "Daemon.h"
|
||||
#else
|
||||
# include "qt/i2pd_qt/i2pd_qt_gui.h"
|
||||
# include <QMessageBox>
|
||||
# include <QApplication>
|
||||
# include "DaemonQT.h"
|
||||
# include "mainwindow.h"
|
||||
# include <QThread>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include "Daemon.h"
|
||||
|
||||
#if defined(QT_GUI_LIB)
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
int RunQT (int argc, char* argv[]);
|
||||
}
|
||||
}
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
#ifdef ANDROID
|
||||
//int result = runGUI(argc, argv);
|
||||
//QMessageBox::information(0,"Debug","runGUI completed");
|
||||
QApplication app(argc, argv);
|
||||
qDebug("Initialising the daemon...");
|
||||
bool daemonInitSuccess = i2p::qt::DaemonQTImpl::init(argc, argv);
|
||||
if(!daemonInitSuccess) {
|
||||
QMessageBox::critical(0, "Error", "Daemon init failed");
|
||||
return 1;
|
||||
}
|
||||
qDebug("Initialised, creating the main window...");
|
||||
MainWindow w;
|
||||
qDebug("Before main window.show()...");
|
||||
w.show ();
|
||||
int result;
|
||||
{
|
||||
i2p::qt::Controller daemonQtController;
|
||||
qDebug("Starting the daemon...");
|
||||
emit daemonQtController.startDaemon();
|
||||
qDebug("Starting gui event loop...");
|
||||
result = app.exec();
|
||||
//QMessageBox::information(&w, "Debug", "exec finished");
|
||||
}
|
||||
i2p::qt::DaemonQTImpl::deinit();
|
||||
//QMessageBox::information(&w, "Debug", "demon stopped");
|
||||
//exit(result); //return from main() causes intermittent sigsegv bugs in some Androids. exit() is a workaround for this
|
||||
qDebug("Exiting the application");
|
||||
return result;
|
||||
return i2p::qt::RunQT (argc, argv);
|
||||
}
|
||||
|
||||
#else
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
if (Daemon.init(argc, argv))
|
||||
{
|
||||
if (Daemon.start())
|
||||
|
@ -48,8 +25,8 @@ int main( int argc, char* argv[] )
|
|||
Daemon.stop();
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue