diff --git a/src/main.cpp b/src/main.cpp index ffc8ea0e7..ebfef29d8 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,14 +76,14 @@ int main(int argc, char *argv[]) { Application application(APP_LOW_NAME, run_minimal_without_gui, argc, argv); qDebug("Instantiated Application class."); - application.feedReader()->start(); - // Check if another instance is running. if (application.sendMessage((QStringList() << APP_IS_RUNNING << application.arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR))) { qWarning("Another instance of the application is already running. Notifying it."); return EXIT_FAILURE; } + application.setFeedReader(new FeedReader(&application)); + // Register needed metatypes. qRegisterMetaType >("QList"); qRegisterMetaType >("QList"); diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index e094290b0..e3e5e3e0f 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -43,7 +43,7 @@ Application::Application(const QString &id, bool run_minimal_without_gui, int &argc, char **argv) : QtSingleApplication(id, argc, argv), - m_runMinimalWithoutGui(run_minimal_without_gui), m_feedReader(new FeedReader(this)), + m_runMinimalWithoutGui(run_minimal_without_gui), m_feedReader(nullptr), m_updateFeedsLock(nullptr), m_userActions(QList()), m_mainForm(nullptr), m_trayIcon(nullptr), m_settings(nullptr), m_system(nullptr), m_skins(nullptr), m_localization(nullptr), m_icons(nullptr), m_database(nullptr), m_downloadManager(nullptr) { @@ -92,9 +92,13 @@ void Application::eliminateFirstRun(const QString &version) { settings()->setValue(GROUP(General), QString(General::FirstRun) + QL1C('_') + version, false); } +void Application::setFeedReader(FeedReader *feed_reader) { + m_feedReader = feed_reader; +} + IconFactory *Application::icons() { - if (m_icons == nullptr) { - m_icons = new IconFactory(this); + if (m_icons == nullptr) { + m_icons = new IconFactory(this); } return m_icons; diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h index dc99de4e1..92c7415ef 100755 --- a/src/miscellaneous/application.h +++ b/src/miscellaneous/application.h @@ -57,6 +57,7 @@ class Application : public QtSingleApplication { virtual ~Application(); FeedReader *feedReader(); + void setFeedReader(FeedReader *feed_reader); // Globally accessible actions. QList userActions(); diff --git a/src/miscellaneous/feedreader.cpp b/src/miscellaneous/feedreader.cpp index 196e92aaf..9f40b7106 100644 --- a/src/miscellaneous/feedreader.cpp +++ b/src/miscellaneous/feedreader.cpp @@ -29,6 +29,11 @@ FeedReader::FeedReader(QObject *parent) : QObject(parent), m_feedServices(QList()) { + m_feedDownloader = new FeedDownloader(this); + m_feedsModel = new FeedsModel(this); + m_feedProxyModel = new FeedsProxyModel(m_feedsModel, this); + m_messagesModel = new MessagesModel(this); + m_messagesProxyModel = new MessagesProxyModel(m_messagesModel, this); } FeedReader::~FeedReader() { @@ -60,15 +65,9 @@ MessagesModel *FeedReader::messagesModel() const { } void FeedReader::start() { - m_feedDownloader = new FeedDownloader(this); - m_feedsModel = new FeedsModel(this); - m_feedProxyModel = new FeedsProxyModel(m_feedsModel, this); - m_messagesModel = new MessagesModel(this); - m_messagesProxyModel = new MessagesProxyModel(m_messagesModel, this); } void FeedReader::stop() { - } MessagesProxyModel *FeedReader::messagesProxyModel() const {