mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 06:28:03 -06:00
MainWindow cleanups.
All MainWindow child widgets use constructors with 'parent' parameter that allows parent widget to delete them at its destruction. Some other MainWindow cleanup code replaced to destructor. Application manages MainWindow instance and remove it when aboutToQuit() signal emitted.
This commit is contained in:
@@ -52,17 +52,15 @@
|
||||
#endif
|
||||
|
||||
#include "application.h"
|
||||
#include "logger.h"
|
||||
#include "preferences.h"
|
||||
#include "qbtsession.h"
|
||||
#include "logger.h"
|
||||
#include "torrentpersistentdata.h"
|
||||
|
||||
static const char PARAMS_SEPARATOR[] = "|";
|
||||
|
||||
Application::Application(const QString &id, int &argc, char **argv)
|
||||
: BaseApplication(id, argc, argv)
|
||||
#ifndef DISABLE_GUI
|
||||
, m_window(0)
|
||||
#endif
|
||||
, m_running(false)
|
||||
{
|
||||
#if defined(Q_OS_MACX) && !defined(DISABLE_GUI)
|
||||
@@ -80,14 +78,7 @@ Application::Application(const QString &id, int &argc, char **argv)
|
||||
#endif
|
||||
|
||||
connect(this, SIGNAL(messageReceived(const QString &)), SLOT(processMessage(const QString &)));
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QBtSession::drop();
|
||||
Preferences::drop();
|
||||
Logger::drop();
|
||||
connect(this, SIGNAL(aboutToQuit()), SLOT(cleanup()));
|
||||
}
|
||||
|
||||
void Application::processMessage(const QString &message)
|
||||
@@ -101,6 +92,17 @@ void Application::processMessage(const QString &message)
|
||||
m_paramsQueue.append(params);
|
||||
}
|
||||
|
||||
void Application::cleanup()
|
||||
{
|
||||
#ifndef DISABLE_GUI
|
||||
delete m_window;
|
||||
#endif
|
||||
QBtSession::drop();
|
||||
TorrentPersistentData::drop();
|
||||
Preferences::drop();
|
||||
Logger::drop();
|
||||
}
|
||||
|
||||
bool Application::sendParams(const QStringList ¶ms)
|
||||
{
|
||||
return sendMessage(params.join(QLatin1String(PARAMS_SEPARATOR)));
|
||||
@@ -181,12 +183,7 @@ int Application::exec(const QStringList ¶ms)
|
||||
m_paramsQueue.clear();
|
||||
}
|
||||
|
||||
int res = BaseApplication::exec();
|
||||
#ifndef DISABLE_GUI
|
||||
delete m_window;
|
||||
#endif
|
||||
qDebug("Application has exited");
|
||||
return res;
|
||||
return BaseApplication::exec();
|
||||
}
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
|
||||
Reference in New Issue
Block a user