Skip to content

Commit

Permalink
fixed a crashing problem related to accessing a deleted pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
AmericanEnglish committed Nov 24, 2017
1 parent 56e6bb4 commit 64d9f8a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cpp/rsearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void rSearch::run() {
else {
qDebug() << "=rSearch: Finished!";
}
delete stopped;
// delete stopped;
// Finished
emit finished();
}
Expand Down
8 changes: 5 additions & 3 deletions cpp/widgets/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void MainWindow::run() {
std::cout << "Liquidation of assests complete" << std::endl;
QStringList allFiles = defaultPath.entryList();
allFiles = allFiles.filter(filepattern);
// qDebug() << allFiles;
qDebug() << allFiles;
// allFiles.removeOne(".");
// allFiles.removeOne("..");
// qDebug() << allFiles;
Expand All @@ -190,14 +190,16 @@ void MainWindow::run() {
// delete noresults;
// }
if (reader == nullptr) {
// std::cout << "Opening New Reader..." << std::endl;
qDebug() << "Opening New Reader...";// << std::endl;
reader = new Reader(defaultPath.absolutePath() + "\\", allFiles, datez->liquidate(), parameters);
reader->show();
}
else {
// std::cout << "Refreshing Old Reader.." << std::endl;
qDebug() << "Refreshing Old Reader..."; // << std::endl;
reader->clear();
qDebug() << "Cleared out old data!";
reader->show();
qDebug() << "Brought Reader to foreground!";
reader->newSearch(defaultPath.absolutePath() + "\\", allFiles, datez->liquidate(), parameters);
}

Expand Down
7 changes: 6 additions & 1 deletion cpp/widgets/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,29 @@ void Reader::updateContent(QModelIndex index) {

void Reader::stopExecution() {
// Stops QThread if it's still running
if (searchThd->isRunning()) {
qDebug() << "Nullptr?:" << (searchThd == nullptr);
if (searchThd != nullptr) {
*stopped = true;
}
}

void Reader::clear() {
stopExecution();
qDebug() << "+Reader: Stopped old thread execution!";
if (poll->isActive()) {
poll->stop();
}
qDebug() << "+Reader: Stopped old timer";
tickCount = 0;
totalComplete = 0;
qDeleteAll(alltables);
alltables.clear();
treeModel->clear();
allData.clear();
qDebug() << "+Reader: Cleared tables, tree, and data!";
stopped = new bool;
*stopped = false;
qDebug() << "+Reader: Refreshed stopped boolean!";
}

void Reader::tRefresh() {
Expand Down
1 change: 1 addition & 0 deletions headers/rsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class rSearch : public QObject {

public:
rSearch(QStringList Dates, QMap<QString, QRegularExpression> Params, QString Base, QStringList Files, QStringList *Entries, bool *Complete);
~rSearch() {qDebug() << "=rSearch Destroyed!";}
// Variables
QStringList dates;
QMap<QString, QRegularExpression> params;
Expand Down

0 comments on commit 64d9f8a

Please sign in to comment.