File indexing completed on 2025-01-19 03:53:31
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-03-23 0007 * Description : Core database convenience object for transactions. 0008 * 0009 * SPDX-FileCopyrightText: 2007-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "coredbtransaction.h" 0016 0017 // Local includes 0018 0019 #include "coredb.h" 0020 #include "coredbaccess.h" 0021 #include "coredbbackend.h" 0022 0023 namespace Digikam 0024 { 0025 0026 CoreDbTransaction::CoreDbTransaction() 0027 : m_access(nullptr) 0028 { 0029 CoreDbAccess access; 0030 access.backend()->beginTransaction(); 0031 } 0032 0033 CoreDbTransaction::CoreDbTransaction(CoreDbAccess* const access) 0034 : m_access(access) 0035 { 0036 m_access->backend()->beginTransaction(); 0037 } 0038 0039 CoreDbTransaction::~CoreDbTransaction() 0040 { 0041 if (m_access) 0042 { 0043 m_access->backend()->commitTransaction(); 0044 } 0045 else 0046 { 0047 CoreDbAccess access; 0048 access.backend()->commitTransaction(); 0049 } 0050 } 0051 0052 } // namespace Digikam