Fixed crash in GxsIdDetails::process (GxsIdDetails::mInstance == NULL) by adding one global instance of GxsIdDetails.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8149 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-04-20 22:28:19 +00:00
parent a9ba944e27
commit a0631e3991
4 changed files with 34 additions and 7 deletions

View File

@ -23,7 +23,7 @@ E [X] it's not possible to create a Forum thread without a Owner.
[X] the tooltip over GXS ids should show the avatar on the left side.
[X] fix data race between GXS ID default icons
[X] Share of key shows "Not implemented". Since forums are public, share key should be hidden.
[ ] switching between forums might cause a crash. Seems to be due to GxsIdDetails::instance not always initialised when used.
[X] switching between forums might cause a crash. Seems to be due to GxsIdDetails::instance not always initialised when used.
GUI General
E [ ] do we keep "Getting Started" ? the look needs to be improved. Any help doing this is welcome!

View File

@ -73,6 +73,25 @@ GxsIdDetails::~GxsIdDetails()
{
}
void GxsIdDetails::initialize()
{
if (mInstance) {
return;
}
mInstance = new GxsIdDetails;
}
void GxsIdDetails::cleanup()
{
if (!mInstance) {
return;
}
delete(mInstance);
mInstance = NULL;
}
void GxsIdDetails::objectDestroyed(QObject *object)
{
if (!object) {
@ -167,8 +186,6 @@ void GxsIdDetails::timerEvent(QTimerEvent *event)
if (mPendingData.empty()) {
/* All done */
mInstance = NULL;
deleteLater();
} else {
/* Start timer */
doStartTimer();
@ -216,10 +233,12 @@ bool GxsIdDetails::process(const RsGxsId &id, GxsIdDetailsCallbackFunction callb
/* Add id to the pending list */
if (!mInstance) {
mInstance = new GxsIdDetails;
mInstance->moveToThread(qApp->thread());
/* GxsIdDetails not initialized. Please use ::initialize */
callback(GXS_ID_DETAILS_TYPE_FAILED, details, object, data);
return false;
}
callback(GXS_ID_DETAILS_TYPE_LOADING, details, object, data);
callback(GXS_ID_DETAILS_TYPE_LOADING, details, object, data);
CallbackData pendingData;
pendingData.mId = id;

View File

@ -57,6 +57,9 @@ public:
GxsIdDetails();
virtual ~GxsIdDetails();
static void initialize();
static void cleanup();
/* Information */
static bool MakeIdDesc(const RsGxsId &id, bool doIcons, QString &desc, QList<QIcon> &icons, QString& comment);

View File

@ -40,6 +40,7 @@
#include <retroshare/rsversion.h>
#include <lang/languagesupport.h>
#include "gui/settings/rsharesettings.h"
#include "gui/gxs/GxsIdDetails.h"
#include "rshare.h"
@ -160,12 +161,16 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
/* Switch off auto shutdown */
setQuitOnLastWindowClosed ( false );
/* Initialize GxsIdDetails */
GxsIdDetails::initialize();
}
/** Destructor */
Rshare::~Rshare()
{
/* Cleanup GxsIdDetails */
GxsIdDetails::cleanup();
}
QString Rshare::retroshareVersion(bool withRevision)