diff --git a/window.cpp b/window.cpp index 516e8bb44bd2e465c922b7201f1bf670c48bea5f..4c934172cd6cf1a50cd6680979d5b12503fad567 100644 --- a/window.cpp +++ b/window.cpp @@ -80,7 +80,7 @@ Window::Window(QWidget *parent) void Window::solveButtonClicked() { - std::list<History *> hist; + std::list<History> hist; bool backtracking = false; srand(time(NULL)); // random seed while (1) @@ -89,20 +89,20 @@ void Window::solveButtonClicked() delay(m_delay); if (backtracking) { - hist.back()->cell->un(); - if (hist.back()->index.size() == 0) + hist.back().cell->un(); + if (hist.back().index.size() == 0) { hist.pop_back(); continue; } backtracking = false; - int choiceNr = rand() % hist.back()->index.size(); // choose a random number; + int choiceNr = rand() % hist.back().index.size(); // choose a random number; repaint(); // draw cells again delay(m_delay); - hist.back()->cell->collapse(hist.back()->index[choiceNr]); // collapse cell with chosen number; + hist.back().cell->collapse(hist.back().index[choiceNr]); // collapse cell with chosen number; std::vector<int>::iterator it; - it = hist.back()->index.begin() + choiceNr; - hist.back()->index.erase(it); + it = hist.back().index.begin() + choiceNr; + hist.back().index.erase(it); } else { @@ -140,7 +140,7 @@ void Window::solveButtonClicked() int choiceCell = rand() % b.size(); // choose a random cell int choiceNr = rand() % b[choiceCell]->index.size(); // choose a random number; - hist.push_back(new History(b[choiceCell], b[choiceCell]->index, choiceNr)); + hist.push_back(History(b[choiceCell], b[choiceCell]->index, choiceNr)); b[choiceCell]->collapse(b[choiceCell]->index[choiceNr]); // collapse that random cell with chosen number; } }