diff --git a/TODO.txt b/TODO.txt index 38b6eb793..edc2a2bcd 100644 --- a/TODO.txt +++ b/TODO.txt @@ -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! diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index 2cb4e7faf..3b97e2620 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -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; diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.h b/retroshare-gui/src/gui/gxs/GxsIdDetails.h index 8f2de451b..1a36934c9 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.h +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.h @@ -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 &icons, QString& comment); diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index 61a5c47fd..05c14ff83 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -40,6 +40,7 @@ #include #include #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)