Skip to content

Commit

Permalink
Merge pull request #300 from mikfire/bugs/deletehopcore
Browse files Browse the repository at this point in the history
Closes #116 - Crash at closing after deleting hop
  • Loading branch information
mikfire authored Jul 29, 2016
2 parents 81cc462 + 7bd11d5 commit a98b3ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
6 changes: 0 additions & 6 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1931,12 +1931,6 @@ void MainWindow::closeEvent(QCloseEvent* /*event*/)
// cause any more queries.
setVisible(false);

// Ask the user if they want to save changes, only if the dirty bit has
// been thrown
// We should also make sure the backup db still exists -- there's some edge
// cases where it doesn't.

Database::instance().unload();
}

void MainWindow::copyRecipe()
Expand Down
12 changes: 6 additions & 6 deletions src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,14 @@ void Database::unload()
// The postgres driver wants nothing to do with this. Core gets dumped if
// we try it. Since we don't need to copy things about for postgres...

if ( Brewtarget::dbType() == Brewtarget::SQLITE ) {

QSqlDatabase::database( dbConName, false ).close();

QSqlDatabase::removeDatabase( dbConName );
QSqlDatabase::database( dbConName, false ).close();
QSqlDatabase::removeDatabase( dbConName );

if (loadWasSuccessful && Brewtarget::dbType() == Brewtarget::SQLITE )
{
dbFile.close();
if (loadWasSuccessful)
automaticBackup();
automaticBackup();
}
}

Expand Down Expand Up @@ -663,6 +662,7 @@ void Database::dropInstance()
static QMutex mutex;

mutex.lock();
dbInstance->unload();
delete dbInstance;
dbInstance=0;
mutex.unlock();
Expand Down

0 comments on commit a98b3ed

Please sign in to comment.