Skip to content

Commit

Permalink
ownership, concurrency and and destructor for parser backend manager and
Browse files Browse the repository at this point in the history
cherry picked:
smurfy/fahrplan#269
  • Loading branch information
poetaster committed Apr 7, 2022
1 parent d0a0064 commit 8843b5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/fahrplan_backend_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ FahrplanBackendManager::FahrplanBackendManager(int defaultParser, QObject *paren
currentParserIndex = defaultParser;
}

FahrplanBackendManager::~FahrplanBackendManager()
{
if (m_parser) {
// Parser object will be autodeleted after the thread quits.
m_parser->quit();
}
}

QStringList FahrplanBackendManager::getParserList()
{
QStringList result;
Expand Down Expand Up @@ -73,7 +81,7 @@ void FahrplanBackendManager::setParser(int index)
m_parser->quit();
}

m_parser = new FahrplanParserThread();
m_parser = new FahrplanParserThread(this);
m_parser->init(index);

// Init can fallback to another index if its invalid.
Expand Down
2 changes: 1 addition & 1 deletion src/fahrplan_parser_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public slots:
void run();

private:
bool m_ready;
volatile bool m_ready;
int i_parser;

QStringList m_trainrestrictions;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser_abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ParserAbstract::ParserAbstract(QObject *parent) :

ParserAbstract::~ParserAbstract()
{
//clearJourney();
clearJourney();
delete requestTimeout;
delete NetworkManager;
}
Expand Down

0 comments on commit 8843b5d

Please sign in to comment.