Skip to content

Commit 916e0d5

Browse files
committed
#2074 note-relations: remove unused code
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent ad90ae3 commit 916e0d5

File tree

1 file changed

+13
-50
lines changed

1 file changed

+13
-50
lines changed

src/entities/notesubfolder.cpp

+13-50
Original file line numberDiff line numberDiff line change
@@ -40,60 +40,23 @@ void NoteSubFolder::setParentId(int parentId) { _parentId = parentId; }
4040
bool NoteSubFolder::isFetched() const { return (_id > 0); }
4141

4242
NoteSubFolder NoteSubFolder::fetch(int id, const QString &connectionName) {
43-
auto noteSubFolder = NoteSubFolder();
44-
// bool closeDb = connectionName != QStringLiteral("memory");
45-
bool closeDb = false;
46-
47-
{
48-
// QSqlDatabase db = DatabaseService::getSharedMemoryDatabase(connectionName);
49-
qDebug() << __func__ << " - 'connectionName': " << connectionName;
50-
qDebug() << __func__ << " - 'id': " << id;
51-
52-
// if (connectionName == QStringLiteral("memory")) {
53-
// void* array[50];
54-
// int size = backtrace(array, 50);
55-
// char** messages = backtrace_symbols(array, size);
56-
//
57-
// // Print the stack trace
58-
// for (int i = 0; i < size && messages != nullptr; ++i) {
59-
// qDebug() << "[" << i << "]" << messages[i];
60-
// }
61-
// free(messages);
62-
// }
63-
64-
const QSqlDatabase db = QSqlDatabase::database(connectionName);
65-
66-
// if (!db.open()) {
67-
// qWarning() << "Failed to open database in thread:" << db.lastError().text();
68-
// if (closeDb) {
69-
// QSqlDatabase::removeDatabase(connectionName);
70-
// }
71-
// return {};
72-
// }
73-
74-
QSqlQuery query(db);
75-
query.prepare(QStringLiteral("SELECT * FROM noteSubFolder WHERE id = :id"));
76-
query.bindValue(QStringLiteral(":id"), id);
77-
78-
if (!query.exec()) {
79-
qWarning() << __func__ << ": " << query.lastError();
80-
} else {
81-
if (query.first()) {
82-
noteSubFolder = noteSubFolderFromQuery(query);
83-
}
84-
}
85-
86-
query.finish();
43+
const QSqlDatabase db = QSqlDatabase::database(connectionName);
44+
QSqlQuery query(db);
45+
query.prepare(QStringLiteral("SELECT * FROM noteSubFolder WHERE id = :id"));
46+
query.bindValue(QStringLiteral(":id"), id);
8747

88-
// if (closeDb) {
89-
// db.close();
90-
// }
91-
} // db goes out of scope here
48+
auto noteSubFolder = NoteSubFolder();
9249

93-
if (closeDb) {
94-
QSqlDatabase::removeDatabase(connectionName);
50+
if (!query.exec()) {
51+
qWarning() << __func__ << ": " << query.lastError();
52+
} else {
53+
if (query.first()) {
54+
noteSubFolder = noteSubFolderFromQuery(query);
55+
}
9556
}
9657

58+
query.finish();
59+
9760
return noteSubFolder;
9861
}
9962

0 commit comments

Comments
 (0)