Fixed crash when closing the settings dialog.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5605 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-09-25 23:51:13 +00:00
parent 29e44ddafa
commit 5726c1ec18
4 changed files with 38 additions and 36 deletions

View File

@ -60,14 +60,6 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
#endif #endif
} }
AppearancePage::~AppearancePage()
{
if (wasLoaded()) {
/* reaload style sheet */
Rshare::loadStyleSheet(Settings->getSheetName());
}
}
/** Saves the changes on this page */ /** Saves the changes on this page */
bool AppearancePage::save(QString &errmsg) bool AppearancePage::save(QString &errmsg)
{ {

View File

@ -32,8 +32,6 @@ class AppearancePage : public ConfigPage
public: public:
/** Default Constructor */ /** Default Constructor */
AppearancePage(QWidget * parent = 0, Qt::WFlags flags = 0); AppearancePage(QWidget * parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */
~AppearancePage();
/** Saves the changes on this page */ /** Saves the changes on this page */
virtual bool save(QString &errmsg); virtual bool save(QString &errmsg);

View File

@ -22,6 +22,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <retroshare/rsplugin.h> #include <retroshare/rsplugin.h>
#include <rshare.h>
#include "GeneralPage.h" #include "GeneralPage.h"
#include "DirectoriesPage.h" #include "DirectoriesPage.h"
#include "ServerPage.h" #include "ServerPage.h"
@ -37,6 +38,7 @@
#include "MessagePage.h" #include "MessagePage.h"
#include "ForumPage.h" #include "ForumPage.h"
#include "PluginsPage.h" #include "PluginsPage.h"
#include "rsharesettings.h"
#define IMAGE_GENERAL ":/images/kcmsystem24.png" #define IMAGE_GENERAL ":/images/kcmsystem24.png"
@ -57,6 +59,7 @@ RSettingsWin::RSettingsWin(QWidget * parent, Qt::WFlags flags)
connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int))); connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int)));
connect(applyButton, SIGNAL(clicked( bool )), this, SLOT( saveChanges()) ); connect(applyButton, SIGNAL(clicked( bool )), this, SLOT( saveChanges()) );
connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
} }
RSettingsWin::~RSettingsWin() RSettingsWin::~RSettingsWin()
@ -65,6 +68,14 @@ RSettingsWin::~RSettingsWin()
_instance = NULL; _instance = NULL;
} }
void RSettingsWin::dialogFinished(int result)
{
if (result == Rejected) {
/* reaload style sheet */
Rshare::loadStyleSheet(::Settings->getSheetName());
}
}
/*static*/ void RSettingsWin::showYourself(QWidget *parent, PageType page /* = LastPage*/) /*static*/ void RSettingsWin::showYourself(QWidget *parent, PageType page /* = LastPage*/)
{ {
if(_instance == NULL) { if(_instance == NULL) {

View File

@ -20,43 +20,44 @@
****************************************************************/ ****************************************************************/
#ifndef RSETTINGSWIN_HPP_ #ifndef RSETTINGSWIN_HPP_
# define RSETTINGSWIN_HPP_ #define RSETTINGSWIN_HPP_
# include <QtGui/QDialog>
# include <retroshare-gui/configpage.h>
# include "ui_settings.h"
#include <QtGui/QDialog>
#include <retroshare-gui/configpage.h>
#include "ui_settings.h"
class RSettingsWin: public QDialog, private Ui::Settings class RSettingsWin: public QDialog, private Ui::Settings
{ {
Q_OBJECT Q_OBJECT
public: public:
enum PageType { LastPage = -1, General = 0, Server, Transfer,Relay, enum PageType { LastPage = -1, General = 0, Server, Transfer,Relay,
Directories, Plugins, Notify, Security, Message, Forum, Chat, Appearance, Sound, Fileassociations }; Directories, Plugins, Notify, Security, Message, Forum, Chat, Appearance, Sound, Fileassociations };
static void showYourself(QWidget *parent, PageType page = LastPage); static void showYourself(QWidget *parent, PageType page = LastPage);
static void postModDirectories(bool update_local); static void postModDirectories(bool update_local);
protected: protected:
RSettingsWin(QWidget * parent = 0, Qt::WFlags flags = 0); RSettingsWin(QWidget * parent = 0, Qt::WFlags flags = 0);
~RSettingsWin(); ~RSettingsWin();
void addPage(ConfigPage*) ; void addPage(ConfigPage*) ;
public slots:
//! Go to a specific part of the control panel.
void setNewPage(int page);
private slots: public slots:
/** Called when user clicks "Save Settings" */ //! Go to a specific part of the control panel.
void saveChanges(); void setNewPage(int page);
private: private slots:
void initStackedWidget(); /** Called when user clicks "Save Settings" */
void saveChanges();
void dialogFinished(int result);
private: private:
static RSettingsWin *_instance; void initStackedWidget();
static int lastPage;
private:
static RSettingsWin *_instance;
static int lastPage;
}; };
#endif // !RSETTINGSWIN_HPP_ #endif // !RSETTINGSWIN_HPP_