Fixed Gtk plugin crash

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@117 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent f4efea7849
commit 39a898cd02
  1. 3
      src/lib/FileDialogs.cpp
  2. 8
      src/main.cpp
  3. 9
      src/plugins/gnome/keepassx-gnome.cpp
  4. 8
      src/plugins/gnome/keepassx-gnome.h
  5. 34
      src/plugins/interfaces/IGnomeInit.h
  6. 4
      src/src.pro

@ -19,6 +19,7 @@
***************************************************************************/
#include "FileDialogs.h"
#include <QDir>
IFileDialog* KpxFileDialogs::iFileDialog=NULL;
QtStandardFileDialogs DefaultQtDlgs;
@ -31,7 +32,7 @@ QString KpxFileDialogs::openExistingFile(QWidget* Parent, const QString& Name, c
{
if(iFileDialog==NULL)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs);
//Load History here!
return iFileDialog->openExistingFileDialog(Parent,Title,QString(),Filters);
return iFileDialog->openExistingFileDialog(Parent,Title,QDir::homePath(),Filters);
}

@ -34,6 +34,7 @@
#include "plugins/interfaces/IFileDialog.h"
#include "plugins/interfaces/IKdeInit.h"
#include "plugins/interfaces/IGnomeInit.h"
#include "lib/FileDialogs.h"
#include "main.h"
@ -124,7 +125,12 @@ int main(int argc, char **argv)
if(config.IntegrPlugin==CConfig::KDE){
IKdeInit* kdeinit=qobject_cast<IKdeInit*>(plugin.instance());
app=kdeinit->getMainAppObject(argc,argv);
}
}
if(config.IntegrPlugin==CConfig::GNOME){
IGnomeInit* ginit=qobject_cast<IGnomeInit*>(plugin.instance());
if(!ginit->init(argc,argv))
KpxFileDialogs::setPlugin(NULL);
}
}
}
if(!app) QApplication* app=new QApplication(argc,argv);

@ -23,12 +23,17 @@
#define CSTR(x)(x.toUtf8().data())
Q_EXPORT_PLUGIN2(keepassx_gnome, GnomePlugin)
bool GnomePlugin::init(int argc, char** argv){
int t_argc=argc;
char** t_argv=argv;
return gtk_init_check(&t_argc,&t_argv);
}
QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
unsigned int NumFilters=Filters.size();
GtkWidget *FileDlg;
QString filename;
gtk_init(0,0);
FileDlg=gtk_file_chooser_dialog_new(CSTR(title),NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -68,7 +73,6 @@ GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
for(p;p<filters[i].size();p++){
if(filters[i][p]==' ' || filters[i][p]==')'){
gtk_file_filter_add_pattern(f[i],CSTR(pattern));
qDebug(CSTR(pattern));
pattern=QString();
}
else{
@ -84,7 +88,6 @@ QStringList GnomePlugin::openExistingFilesDialog(QWidget* parent,QString title,Q
unsigned int NumFilters=Filters.size();
GtkWidget *FileDlg;
QStringList filenames;
gtk_init(0,0);
FileDlg=gtk_file_chooser_dialog_new(CSTR(title),NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,

@ -23,11 +23,12 @@
#include <QtPlugin>
#include <QObject>
#include "../interfaces/IFileDialog.h"
#include "../interfaces/IGnomeInit.h"
class GnomePlugin:public QObject,public IFileDialog{
class GnomePlugin:public QObject,public IFileDialog,public IGnomeInit{
Q_OBJECT
Q_INTERFACES(IFileDialog)
Q_INTERFACES(IGnomeInit)
public:
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters);
@ -35,6 +36,7 @@ class GnomePlugin:public QObject,public IFileDialog{
QStringList Filters);
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters,bool ShowOverwriteWarning=true);
virtual bool init(int argc, char** argv);
private:
GtkFileFilter** parseFilterStrings(const QStringList &Filters);
};
};

@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QString>
#include <QStringList>
#include <QApplication>
#ifndef _I_GNOME_INIT_H_
#define _I_GNOME_INIT_H_
class IGnomeInit{
public:
virtual ~IGnomeInit(){}
virtual bool init(int argc, char** argv)=0;
};
Q_DECLARE_INTERFACE(IGnomeInit,"org.KeePassX.GnomeInitInterface/1.0")
#endif

@ -90,7 +90,9 @@ HEADERS += lib/IniReader.h \
crypto/sha256.h \
crypto/yarrow.h \
lib/WaitAnimationWidget.h \
plugins/interfaces/IFileDialog.h
plugins/interfaces/IFileDialog.h \
plugins/interfaces/IKdeInit.h \
plugins/interfaces/IGnomeInit.h
SOURCES += lib/IniReader.cpp \
lib/UrlLabel.cpp \
main.cpp \