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] the tooltip over GXS ids should show the avatar on the left side.
[X] fix data race between GXS ID default icons [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. [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 GUI General
E [ ] do we keep "Getting Started" ? the look needs to be improved. Any help doing this is welcome! 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) void GxsIdDetails::objectDestroyed(QObject *object)
{ {
if (!object) { if (!object) {
@ -167,8 +186,6 @@ void GxsIdDetails::timerEvent(QTimerEvent *event)
if (mPendingData.empty()) { if (mPendingData.empty()) {
/* All done */ /* All done */
mInstance = NULL;
deleteLater();
} else { } else {
/* Start timer */ /* Start timer */
doStartTimer(); doStartTimer();
@ -216,9 +233,11 @@ bool GxsIdDetails::process(const RsGxsId &id, GxsIdDetailsCallbackFunction callb
/* Add id to the pending list */ /* Add id to the pending list */
if (!mInstance) { if (!mInstance) {
mInstance = new GxsIdDetails; /* GxsIdDetails not initialized. Please use ::initialize */
mInstance->moveToThread(qApp->thread()); 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; CallbackData pendingData;

View File

@ -57,6 +57,9 @@ public:
GxsIdDetails(); GxsIdDetails();
virtual ~GxsIdDetails(); virtual ~GxsIdDetails();
static void initialize();
static void cleanup();
/* Information */ /* Information */
static bool MakeIdDesc(const RsGxsId &id, bool doIcons, QString &desc, QList<QIcon> &icons, QString& comment); 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 <retroshare/rsversion.h>
#include <lang/languagesupport.h> #include <lang/languagesupport.h>
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/gxs/GxsIdDetails.h"
#include "rshare.h" #include "rshare.h"
@ -160,12 +161,16 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
/* Switch off auto shutdown */ /* Switch off auto shutdown */
setQuitOnLastWindowClosed ( false ); setQuitOnLastWindowClosed ( false );
/* Initialize GxsIdDetails */
GxsIdDetails::initialize();
} }
/** Destructor */ /** Destructor */
Rshare::~Rshare() Rshare::~Rshare()
{ {
/* Cleanup GxsIdDetails */
GxsIdDetails::cleanup();
} }
QString Rshare::retroshareVersion(bool withRevision) QString Rshare::retroshareVersion(bool withRevision)