Skip to content

Commit

Permalink
fix(mainwindow.cc): fix bugs about saving files
Browse files Browse the repository at this point in the history
  • Loading branch information
ouuan committed Dec 13, 2019
1 parent 1d80075 commit 742ea08
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ void MainWindow::launchSession() {
openFile = nullptr;
}

editor->clear();
runner->removeExecutable();

if (setting->getTemplatePath().size() != 0) {
if (QFile::exists(QString::fromStdString(setting->getTemplatePath()))) {
QFile f(QString::fromStdString(setting->getTemplatePath()));
Expand Down Expand Up @@ -411,8 +414,6 @@ void MainWindow::on_actionNew_triggered() {
if (res == QMessageBox::No)
return;

editor->clear();
runner->removeExecutable();
launchSession();
}
void MainWindow::on_actionOpen_triggered() {
Expand Down Expand Up @@ -864,6 +865,7 @@ void MainWindow::onSaveTimerElapsed() {
if (openFile != nullptr && openFile->isOpen()) {
openFile->resize(0);
openFile->write(editor->toPlainText().toStdString().c_str());
openFile->flush();
Log::MessageLogger::info(
"AutoSave",
"AutoSaved to file : " + openFile->fileName().toStdString());
Expand Down

0 comments on commit 742ea08

Please sign in to comment.