From 6481e28ba0d696cf41a2a5bc32b01db85f95b333 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 27 Jan 2014 16:43:40 +0100 Subject: [PATCH] Fix crashes in QtHelp when too many connections are made Fixes a crash when Qt Creator was registering a large number of .qch files on first startup: In this case the limit of 1000 connections within one session will overflow, resulting in conflicting connection names and crashes later on. Remove this limitation by keeping separate counters per connection name, and also not wrapping around after 1000. It's not clear where the 1000 connection limit stems from: The offending lines predate the first git import of Qt 4. Task-number: QTBUG-36480 Change-Id: If00276652644efa854a75407d00ba01069bde02a Reviewed-by: Karsten Heimrich --- src/assistant/help/qhelp_global.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/assistant/help/qhelp_global.cpp b/src/assistant/help/qhelp_global.cpp index ff97263..795906c 100644 --- a/src/assistant/help/qhelp_global.cpp +++ b/src/assistant/help/qhelp_global.cpp @@ -48,15 +48,13 @@ QString QHelpGlobal::uniquifyConnectionName(const QString &name, void *pointer) { - static int counter = 0; static QMutex mutex; - QMutexLocker locker(&mutex); - if (++counter > 1000) - counter = 0; + + static QHash idHash; return QString::fromLatin1("%1-%2-%3"). - arg(name).arg(quintptr(pointer)).arg(counter); + arg(name).arg(quintptr(pointer)).arg(++idHash[name]); } QString QHelpGlobal::documentTitle(const QString &content) -- 2.7.4