Fix double warning display for database open#744
Fix double warning display for database open#744kortschak wants to merge 3 commits intokeepassxreboot:developfrom
Conversation
phoerious
left a comment
There was a problem hiding this comment.
Technically, it's possible to have a database with an empty key. This patch would prevent those databases from being opened. I would therefore prefer a different implementation (maybe exceptions?)
|
Maybe a valid key should not be returned by |
|
Abandoning. |
|
Maybe the key could also have a property that says if it is a valid key or not. BTW you don't need to abandon this PR. You can just force push anything else over it. |
|
If keeping a state field for validity is acceptable, I'll reopen; using exceptions for this seem obscene to me. |
|
I don't see why that would be obscene. You can't return a nullptr, because the instance is returned by value. Using exceptions would be the cleanest option. But I'd also be fine with an extra attribute. |
|
Just different aesthetics. |
|
C++ programmers seem to never use exceptions, although they are one of the best language features compared to C. |
|
Please take another look. |
|
I have checked that this does not block opening an empty-keyed database by creating a new database without completing the creation dialogue - this leaves the database file created. This database can be opened. |
86745f1 to
09113ad
Compare
SQUASH BEFORE MERGE
ac2933d to
b8a62ac
Compare
|
It is not clear to me how the change here is causing the failure in the gui test (looking at the test and trying to replay it manually, I'm not actually sure what it's trying to do). I can reproduce the failure locally with |
|
You should properly initialize the member variable using an initialization list in both constructors. You should also call it m_isValid or m_valid, not invalid (although that won't be the reason for the error). |
Happy to change the name and orientation. I tried an explicit initialisation in ad875402c5577c024f87c4d353c21aa558ed9f7c, but it made no difference - similarly with the logic inversion here. |
|
That's just a style thing. The compiler will default-initialize the boolean otherwise. |
|
@phoerious exceptions are disabled for the project, using the |
|
Exceptions in c++ are terrible (also not implemented past the basic exception was thrown). Using try/catch programming leads to sloppy choices in architecture in my opinion. |
|
Closing in favor of #1037 |
This change fixes the rapid display and covering of the file not found warning dialogue described in #741.
Description
gui/DatabaseOpenWidget.cpp looks like
DatabaseOpenWidget::openDatabaseaccepts the invalidCompositeKeyreturned byDatabaseWidget::databaseKeyon failure.This change short circuits the call to
file.openin the case that an emptymasterKeyhas been returned to allows the user to see the reason for that failure.Motivation and context
Fixes #741.
How has this been tested?
This has been manually tested using the steps to reproduce at the issue.
Screenshots (if appropriate):
Before change:

After change:

Types of changes
Checklist:
-DWITH_ASAN=ON. [REQUIRED]Note that
-DWITH_ASAN=ONtests fail withHowever this is identical to the behaviour seen with the current develop HEAD 7580c38.