Skip to content

Commit 64d9f8a

Browse files
author
Carlos Barajas
committed
fixed a crashing problem related to accessing a deleted pointer
1 parent 56e6bb4 commit 64d9f8a

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

cpp/rsearch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void rSearch::run() {
5353
else {
5454
qDebug() << "=rSearch: Finished!";
5555
}
56-
delete stopped;
56+
// delete stopped;
5757
// Finished
5858
emit finished();
5959
}

cpp/widgets/mainwindow.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void MainWindow::run() {
175175
std::cout << "Liquidation of assests complete" << std::endl;
176176
QStringList allFiles = defaultPath.entryList();
177177
allFiles = allFiles.filter(filepattern);
178-
// qDebug() << allFiles;
178+
qDebug() << allFiles;
179179
// allFiles.removeOne(".");
180180
// allFiles.removeOne("..");
181181
// qDebug() << allFiles;
@@ -190,14 +190,16 @@ void MainWindow::run() {
190190
// delete noresults;
191191
// }
192192
if (reader == nullptr) {
193-
// std::cout << "Opening New Reader..." << std::endl;
193+
qDebug() << "Opening New Reader...";// << std::endl;
194194
reader = new Reader(defaultPath.absolutePath() + "\\", allFiles, datez->liquidate(), parameters);
195195
reader->show();
196196
}
197197
else {
198-
// std::cout << "Refreshing Old Reader.." << std::endl;
198+
qDebug() << "Refreshing Old Reader..."; // << std::endl;
199199
reader->clear();
200+
qDebug() << "Cleared out old data!";
200201
reader->show();
202+
qDebug() << "Brought Reader to foreground!";
201203
reader->newSearch(defaultPath.absolutePath() + "\\", allFiles, datez->liquidate(), parameters);
202204
}
203205

cpp/widgets/reader.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,24 +219,29 @@ void Reader::updateContent(QModelIndex index) {
219219

220220
void Reader::stopExecution() {
221221
// Stops QThread if it's still running
222-
if (searchThd->isRunning()) {
222+
qDebug() << "Nullptr?:" << (searchThd == nullptr);
223+
if (searchThd != nullptr) {
223224
*stopped = true;
224225
}
225226
}
226227

227228
void Reader::clear() {
228229
stopExecution();
230+
qDebug() << "+Reader: Stopped old thread execution!";
229231
if (poll->isActive()) {
230232
poll->stop();
231233
}
234+
qDebug() << "+Reader: Stopped old timer";
232235
tickCount = 0;
233236
totalComplete = 0;
234237
qDeleteAll(alltables);
235238
alltables.clear();
236239
treeModel->clear();
237240
allData.clear();
241+
qDebug() << "+Reader: Cleared tables, tree, and data!";
238242
stopped = new bool;
239243
*stopped = false;
244+
qDebug() << "+Reader: Refreshed stopped boolean!";
240245
}
241246

242247
void Reader::tRefresh() {

headers/rsearch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class rSearch : public QObject {
1616

1717
public:
1818
rSearch(QStringList Dates, QMap<QString, QRegularExpression> Params, QString Base, QStringList Files, QStringList *Entries, bool *Complete);
19+
~rSearch() {qDebug() << "=rSearch Destroyed!";}
1920
// Variables
2021
QStringList dates;
2122
QMap<QString, QRegularExpression> params;

0 commit comments

Comments
 (0)