Fixed: database could be automatically locked while a file dialog is opened

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@184 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 17 years ago
parent a85dbe65fa
commit d359363e7f
  1. 1
      src/keepassx.h
  2. 6
      src/lib/FileDialogs.cpp
  3. 1
      src/main.cpp
  4. 5
      src/mainwindow.cpp

@ -102,6 +102,7 @@ extern bool TrActive;
extern QString DetailViewTemplate; extern QString DetailViewTemplate;
extern QPixmap *EntryIcons; extern QPixmap *EntryIcons;
extern bool EventOccurred; extern bool EventOccurred;
extern bool EventOccurredBlock;
#endif //__cplusplus #endif //__cplusplus
#endif //KEEPASS_X_ #endif //KEEPASS_X_

@ -29,6 +29,7 @@ void KpxFileDialogs::setPlugin(IFileDialog* plugin){
QString KpxFileDialogs::openExistingFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,QString Dir,int SelectedFilter) QString KpxFileDialogs::openExistingFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,QString Dir,int SelectedFilter)
{ {
EventOccurredBlock = true;
if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs); if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs);
if(Dir==QString()) if(Dir==QString())
Dir=fileDlgHistory.getDir(Name); Dir=fileDlgHistory.getDir(Name);
@ -38,11 +39,13 @@ QString KpxFileDialogs::openExistingFile(QWidget* Parent, const QString& Name, c
if(!result.isEmpty()){ if(!result.isEmpty()){
fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter()); fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter());
} }
EventOccurredBlock = false;
return result; return result;
} }
QStringList KpxFileDialogs::openExistingFiles(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,QString Dir,int SelectedFilter) QStringList KpxFileDialogs::openExistingFiles(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,QString Dir,int SelectedFilter)
{ {
EventOccurredBlock = true;
if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs); if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs);
if(Dir==QString()) if(Dir==QString())
Dir=fileDlgHistory.getDir(Name); Dir=fileDlgHistory.getDir(Name);
@ -52,11 +55,13 @@ QStringList KpxFileDialogs::openExistingFiles(QWidget* Parent, const QString& Na
if(!results.isEmpty()){ if(!results.isEmpty()){
fileDlgHistory.set(Name,results[0].left(results[0].lastIndexOf("/")+1),iFileDialog->getLastFilter()); fileDlgHistory.set(Name,results[0].left(results[0].lastIndexOf("/")+1),iFileDialog->getLastFilter());
} }
EventOccurredBlock = false;
return results; return results;
} }
QString KpxFileDialogs::saveFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,bool OverWriteWarn,QString Dir,int SelectedFilter) QString KpxFileDialogs::saveFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,bool OverWriteWarn,QString Dir,int SelectedFilter)
{ {
EventOccurredBlock = true;
if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs); if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs);
if(Dir==QString()) if(Dir==QString())
Dir=fileDlgHistory.getDir(Name); Dir=fileDlgHistory.getDir(Name);
@ -66,6 +71,7 @@ QString KpxFileDialogs::saveFile(QWidget* Parent, const QString& Name, const QSt
if(!result.isEmpty()){ if(!result.isEmpty()){
fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter()); fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter());
} }
EventOccurredBlock = false;
return result; return result;
} }

@ -45,6 +45,7 @@ QString PluginLoadError;
bool TrActive; bool TrActive;
QString DetailViewTemplate; QString DetailViewTemplate;
bool EventOccurred; bool EventOccurred;
bool EventOccurredBlock = false;
QPixmap* EntryIcons; QPixmap* EntryIcons;
IIconTheme* IconLoader=NULL; IIconTheme* IconLoader=NULL;

@ -1245,13 +1245,10 @@ void KeepassMainWindow::OnInactivityTimer(){
if (IsLocked || !FileOpen) if (IsLocked || !FileOpen)
return; return;
QWidgetList widgets = QApplication::topLevelWidgets(); if (QApplication::activeModalWidget()!=NULL || EventOccurredBlock){
for (int i=0; i<widgets.size(); i++){
if (widgets[i]->windowModality()==Qt::ApplicationModal){
inactivityCounter = 0; inactivityCounter = 0;
return; return;
} }
}
if (EventOccurred){ if (EventOccurred){
inactivityCounter = 0; inactivityCounter = 0;