Skip to content

Commit

Permalink
Closes #116 - Crash at closing after deleting hop
Browse files Browse the repository at this point in the history
Deleting had nothing to do with it, but adding a new hop did. For reasons I
still do NOT understand, the hop table was attempting to refresh itself on
delete. I went through any number of interations, but could never quite figure
out why.

This is the easiest of the fixes I found -- the database isn't closed until
after we tear all the windows down. Since MainWindow doesn't open the DB, it
shouldn't close it either. I still cannot explain why the hop editor alone
does this, and not the misc editor.
  • Loading branch information
mikfire committed Jul 27, 2016
1 parent 6fc32f2 commit 7bd11d5
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 @@ -543,15 +543,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 @@ -664,6 +663,7 @@ void Database::dropInstance()
static QMutex mutex;

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

0 comments on commit 7bd11d5

Please sign in to comment.