gui(forums): create reload timer before setGroupId (fix ctor SIGSEGV)

The coalescing timer was allocated near the end of the constructor, but
setGroupId(forumId) is called earlier and synchronously reaches
groupIdChanged() -> updateDisplay(true) -> mDeferredReloadTimer->stop(),
dereferencing the still-uninitialised pointer and crashing the moment a forum
was opened. Allocate the timer right after setupUi(), before setGroupId().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jolavillette 2026-07-25 08:40:05 +02:00
parent 839293f84d
commit 3860f76dc1

View File

@ -254,6 +254,13 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
{
ui->setupUi(this);
// Single-shot timer used to coalesce the full-forum reloads requested by
// incoming GXS events (see scheduleForumReload()). Created first thing:
// setGroupId(forumId) below reaches updateDisplay(), which touches this timer.
mDeferredReloadTimer = new QTimer(this);
mDeferredReloadTimer->setSingleShot(true);
connect(mDeferredReloadTimer, &QTimer::timeout, this, [this]() { updateDisplay(true); });
//setUpdateWhenInvisible(true);
//mUpdating = false;
@ -375,12 +382,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
ui->threadTreeWidget->enableColumnCustomize(true);
#endif
// Single-shot timer used to coalesce the full-forum reloads requested by
// incoming GXS events (see scheduleForumReload()).
mDeferredReloadTimer = new QTimer(this);
mDeferredReloadTimer->setSingleShot(true);
connect(mDeferredReloadTimer, &QTimer::timeout, this, [this]() { updateDisplay(true); });
mEventHandlerId = 0;
// Needs to be asynced because this function is called by another thread!
rsEvents->registerEventsHandler(