Fix qute://version sql init bug.

Calling sql.init() in version.version() would replace the existing sql
connection and cause a crash when accessed by opening qute://version.

Now version relies on sql already being initted, and app.py inits sql early if
the --version arg is given.
This commit is contained in:
Ryan Roden-Corrent 2017-04-11 08:12:23 -04:00
parent 231bbe7c2b
commit a8ed9f1c2f
4 changed files with 12 additions and 5 deletions

View File

@ -83,6 +83,9 @@ def run(args):
standarddir.init(args)
if args.version:
# we need to init sql to print the sql version
# we can use an in-memory database as we just want to query the version
sql.init('')
print(version.version())
sys.exit(usertypes.Exit.ok)

View File

@ -326,11 +326,7 @@ def version():
lines += _module_versions()
lines += ['pdf.js: {}'.format(_pdfjs_version())]
# we can use an in-memory database as we just want to query the version
sql.init('')
lines += ['sqlite: {}'.format(sql.version())]
sql.close()
lines += [
'SSL: {}'.format(QSslSocket.sslLibraryVersionString()),

View File

@ -702,3 +702,11 @@ Feature: Various utility commands.
And I wait for "Renderer process was killed" in the log
And I open data/numbers/3.txt
Then no crash should happen
And the following tabs should be open:
- data/numbers/3.txt (active)
## Other
Scenario: Open qute://version
When I open qute://version
Then the page should contain the plaintext "Version info"

View File

@ -809,7 +809,7 @@ def test_chromium_version_unpatched(qapp):
(True, False, True, True, False), # unknown Linux distribution
])
def test_version_output(git_commit, frozen, style, with_webkit,
known_distribution, stubs, monkeypatch):
known_distribution, stubs, monkeypatch, init_sql):
"""Test version.version()."""
class FakeWebEngineProfile:
def httpUserAgent(self):