Skip to content

Commit

Permalink
Allow users to open a new database even if one is already open
Browse files Browse the repository at this point in the history
Since Open is a subclass of DatabaseCommand, it would previously be a
no-op if a database was already opened. This change causes the Open
command to reset the current database to nullptr before executing,
allowing a new database to be opened.
  • Loading branch information
sjamesr committed Aug 20, 2019
1 parent 81885d0 commit ec27e48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli/Open.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "Open.h"

#include <QtCore/QCommandLineParser>
#include <QCommandLineParser>

#include "DatabaseCommand.h"
#include "TextStream.h"
Expand All @@ -29,6 +29,12 @@ Open::Open()
description = QObject::tr("Open a database.");
}

int Open::execute(const QStringList& arguments)
{
currentDatabase.reset(nullptr);
return this->DatabaseCommand::execute(arguments);
}

int Open::executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser)
{
Q_UNUSED(parser)
Expand Down
1 change: 1 addition & 0 deletions src/cli/Open.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Open : public DatabaseCommand
{
public:
Open();
int execute(const QStringList& arguments) override;
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
};

Expand Down

0 comments on commit ec27e48

Please sign in to comment.