Feature #62

Ability to auto-lock the database

Added by gf th over 6 years ago. Updated over 5 years ago.

Target version:


There only a lock button in KeepassX 2.0 alpha 3 but no auto-lock and timer option.
Test on Linux Mint 13 Cinnamon 64 bits.

Feature #35
Currently there is no way to lock the database. The Windows version can lock the database with a button press and can even automatically lock the database after a set time frame or when the screensaver comes on. I do not like having my database unlocked while I am not at my desk, and the auto-lock feature is incredibly useful to keep me from having two databases open from different locations.

Related issues

Duplicated by Feature #128: Close automatically Closed 12/10/2013
Duplicated by Feature #157: KeepassX 2.0 a5 / No (settings for) auto logout Closed 03/06/2014

Associated revisions

Revision a8edad1e
Added by Felix Geyer over 5 years ago

Add option to lock databases after user inactivity.

Closes #62


#1 Updated by Felix Geyer about 6 years ago

  • Priority changed from Normal to High
  • Target version set to 2.0 Alpha 5

#2 Updated by shale craig over 5 years ago

Tested Alpha 4 on Mac OS X 10.7.5:

The database will lock with [command]+L, but there is no functionality to automatically lock the database on a timeout.

Under the Database menu option, there is a "Lock Databases" option ([Command]+L).

#3 Updated by Wade Dugas over 5 years ago

I developed this for the alpha 4 version and tested it on OS X 10.8.5. It includes the ability to enable it and change the timeout value in Preferences/Security. I haven't tested it on Linux.

Perhaps someone here can let me know the procedures used for code review and check-in to GitHub.

#4 Updated by Felix Geyer over 5 years ago

Thanks for working on this feature :)
The preferred method is to fork the repository on github (, then push your commits to the forked repo and open a pull request. has some more details.

#5 Updated by Wade Dugas over 5 years ago

I opened a pull request as requested.

I have a couple of thoughts/comments:

I started developing against code I cloned on Sep 24. Everything was tested and working as expected. I then applied my changes to the fork I created on Oct 17. The app would crash on startup with a bad pointer to config. I corrected the issue by creating my own pointer to config. Instead of using config()->get, I created Config* m_config = config() in MainWindow.h and then used m_config. The error (EXC_BAD_ACCESS(Code 2)) was occurring in my event filter, but only after being called many times. Not calling config() every time seems to have fixed it. Let me know if anybody has an idea why this started occurring and why the fix fixed it.

Also, an additional nice-to-have feature would be to temporarily save any entries/groups being created or edited when the database is locked. If a user creates or edits and entry/group, the database is auto-locked or locked by the user, then the user closes the app -> all changes are lost without warning. This currently happens if you lock the database manually and then close the app. At least, there should be a warning asking if you want to save your work before closing. Better would be the option to temporarily save the work so the next time the app is opened the user is able to continue editing/creating where they left off. Thoughts???

#6 Updated by Wade Dugas over 5 years ago

I tracked down the issue with the bad pointer. The config needs to be initialized before it is called in the event filter. I'm still not sure why the call doesn't work from the event filter, but this fixes the problem.

I checked in again and:

- Reverted back to using config() instead of creating a new pointer m_config.
- added a call to config() in the code block installing the event filter. This insures config is instantiated before the event filter is invoked.

#7 Updated by Felix Geyer over 5 years ago

  • Target version changed from 2.0 Alpha 5 to 2.0 Alpha 6

#8 Updated by Felix Geyer over 5 years ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

Also available in: Atom PDF