Skip to content

Commit 1e787b4

Browse files
committed
sqbpro: Allow relative database file paths
When the path to the database file given in a project file doesn't exist try parsing it relative to the path of the loaded project file. This makes it possible to move project and database file around together without need to manually correct the path in the project file. See sqlitebrowser#36.
1 parent daf12d4 commit 1e787b4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/MainWindow.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,10 @@ bool MainWindow::loadProject(QString filename)
17201720
if(xml.name() == "db")
17211721
{
17221722
// DB file
1723-
fileOpen(xml.attributes().value("path").toString());
1723+
QString dbfilename = xml.attributes().value("path").toString();
1724+
if(!QFile::exists(dbfilename))
1725+
dbfilename = QFileInfo(filename).absolutePath() + QDir::separator() + dbfilename;
1726+
fileOpen(dbfilename);
17241727
ui->dbTreeWidget->collapseAll();
17251728
} else if(xml.name() == "window") {
17261729
// Window settings

0 commit comments

Comments
 (0)