<table><tr><td style="">bruns created this revision.<br />bruns added a reviewer: Frameworks.<br />Herald added a project: Plasma.<br />Herald added a subscriber: plasma-devel.<br />bruns requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D16409">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>QSqlDatabase connection instances are global reference counted objects which<br />
can be crated using the QSqlDatabase::addDatabase(...) method and later<br />
retrieved with QSqlDatabase::database(connectionname).</p>

<p>Connections should only be used from a single thread, and should be cleaned<br />
up with QSD::removeDatabase(name), which implicitly closes the connection<br />
when the last reference is removed.</p>

<p>Currently, the same connection (name) is reused over all threads, and<br />
the connection is only removed implicitly by replacing it via addDatabase().<br />
This leads to warnings, i.e.: "QSqlDatabasePrivate::addDatabase: duplicate<br />
connection name '...', old connection removed."</p>

<p>As one reference is held by the m_db member, the implicit removal triggers<br />
another warning: "QSqlDatabasePrivate::removeDatabase: connection '..."<br />
is still in use, all queries will cease to work."</p>

<p>According to the documentation, "It is highly recommended that you do not<br />
keep a copy of the QSqlDatabase around as a member of a class, as this<br />
will prevent the instance from being correctly cleaned up on shutdown."<br />
There is no need to keep a reference using a member variable, as retrieving<br />
an open connection via QSqlDatabase::database(...) is cheap.</p>

<p>Create a per-thread DB connection on first use, and remove the connections<br />
when the FetchSqlite instance is torn down.</p>

<p>Delaying the open is beneficial for the favicon instance, which may be<br />
unused when the icon is already cached on disk.</p>

<p>See also <a href="https://phabricator.kde.org/T9626" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">T9626</a>.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>execute a query in krunner</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Results are as expected</li>
<li class="remarkup-list-item">The 'QSqlDatabasePrivate::removeDatabase: connection ... is still in use, all queries will cease to work.' warning no longer appears</li>
<li class="remarkup-list-item">The 'QSqlDatabasePrivate::addDatabase: duplicate connection name ..., old connection removed' warning no longer appears</li>
</ol></div></div><br /><div><strong>REPOSITORY</strong><div><div>R120 Plasma Workspace</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D16409">https://phabricator.kde.org/D16409</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>runners/bookmarks/fetchsqlite.cpp<br />
runners/bookmarks/fetchsqlite.h</div></div></div><br /><div><strong>To: </strong>bruns, Frameworks<br /><strong>Cc: </strong>plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br /></div>