Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Avoid double-lookup: contains() + [] -> find() + iterator

parent b39b341b
......@@ -103,8 +103,8 @@ void KDevelopSessionsEngine::updateSessions()
{
const Session& session = it2.value();
if ( !m_currentSessions.contains( session.hash ) )
{
auto sessionIt = m_currentSessions.constFind(session.hash);
if (sessionIt == m_currentSessions.constEnd()) {
// Publish new session.
m_currentSessions.insert( session.hash, session );
......@@ -115,7 +115,7 @@ void KDevelopSessionsEngine::updateSessions()
{
// Publish data changes for older sessions.
Session oldSession( m_currentSessions.value(session.hash) );
Session oldSession(*sessionIt);
bool modified = false;
......
......@@ -120,8 +120,9 @@ void IBreakpointController::breakpointModelChanged(int row, BreakpointModel::Col
for (int column = 0; column < BreakpointModel::NumColumns; ++column) {
if (columns & (1 << column)) {
m_dirty[breakpoint].insert(Breakpoint::Column(column));
if (m_errors.contains(breakpoint)) {
m_errors[breakpoint].remove(Breakpoint::Column(column));
auto errorIt = m_errors.find(breakpoint);
if (errorIt != m_errors.end()) {
errorIt->remove(Breakpoint::Column(column));
}
}
}
......
......@@ -398,11 +398,12 @@ VariablesRoot::VariablesRoot(TreeModel* model)
Locals* VariablesRoot::locals(const QString& name)
{
if (!m_locals.contains(name)) {
m_locals[name] = new Locals(model(), this, name);
appendChild(m_locals[name]);
auto localsIt = m_locals.find(name);
if (localsIt == m_locals.end()) {
localsIt = m_locals.insert(name, new Locals(model(), this, name));
appendChild(*localsIt);
}
return m_locals[name];
return *localsIt;
}
QHash<QString, Locals*> VariablesRoot::allLocals() const
......
......@@ -81,12 +81,12 @@ QList<QAction*> ContextMenuExtension::actions( const QString& group ) const
void ContextMenuExtension::addAction( const QString& group, QAction* action )
{
if( !d->extensions.contains( group ) )
{
auto actionGroupIt = d->extensions.find(group);
if (actionGroupIt == d->extensions.end()) {
d->extensions.insert( group, QList<QAction*>() << action );
} else
{
d->extensions[group].append( action );
actionGroupIt->append(action);
}
}
......
......@@ -633,21 +633,23 @@ void BackgroundParser::removeDocument(const IndexedString& url, QObject* notifyW
QMutexLocker lock(&d->m_mutex);
if (d->m_documents.contains(url)) {
d->m_documentsForPriority[d->m_documents[url].priority()].remove(url);
auto documentParsePlanIt = d->m_documents.find(url);
if (documentParsePlanIt != d->m_documents.end()) {
auto& documentParsePlan = *documentParsePlanIt;
d->m_documentsForPriority[documentParsePlan.priority()].remove(url);
foreach (const DocumentParseTarget& target, d->m_documents[url].targets) {
foreach (const DocumentParseTarget& target, documentParsePlan.targets) {
if (target.notifyWhenReady.data() == notifyWhenReady) {
d->m_documents[url].targets.remove(target);
documentParsePlan.targets.remove(target);
}
}
if (d->m_documents[url].targets.isEmpty()) {
d->m_documents.remove(url);
if (documentParsePlan.targets.isEmpty()) {
d->m_documents.erase(documentParsePlanIt);
--d->m_maxParseJobs;
} else {
//Insert with an eventually different priority
d->m_documentsForPriority[d->m_documents[url].priority()].insert(url);
d->m_documentsForPriority[documentParsePlan.priority()].insert(url);
}
}
}
......@@ -866,20 +868,22 @@ void BackgroundParser::documentClosed(IDocument* document)
if (document->textDocument()) {
KTextEditor::Document* textDocument = document->textDocument();
if (!d->m_managedTextDocumentUrls.contains(textDocument))
auto documentUrlIt = d->m_managedTextDocumentUrls.find(textDocument);
if (documentUrlIt == d->m_managedTextDocumentUrls.end())
return; // Probably the document had an invalid url, and thus it wasn't added to the background parser
Q_ASSERT(d->m_managedTextDocumentUrls.contains(textDocument));
Q_ASSERT(documentUrlIt != d->m_managedTextDocumentUrls.end());
IndexedString url(d->m_managedTextDocumentUrls[textDocument]);
IndexedString url(*documentUrlIt);
QMutexLocker l2(&d->m_managedMutex);
Q_ASSERT(d->m_managed.contains(url));
auto urlIt = d->m_managed.find(url);
Q_ASSERT(urlIt != d->m_managed.end());
qCDebug(LANGUAGE) << "removing" << url.str() << "from background parser";
delete d->m_managed[url];
d->m_managedTextDocumentUrls.remove(textDocument);
d->m_managed.remove(url);
delete *urlIt;
d->m_managedTextDocumentUrls.erase(documentUrlIt);
d->m_managed.erase(urlIt);
}
}
......@@ -893,7 +897,8 @@ void BackgroundParser::documentLoaded(IDocument* document)
// Some debugging because we had issues with this
QMutexLocker l2(&d->m_managedMutex);
if (d->m_managed.contains(url) && d->m_managed[url]->document() == textDocument) {
auto urlIt = d->m_managed.find(url);
if (urlIt != d->m_managed.end() && (*urlIt)->document() == textDocument) {
qCDebug(LANGUAGE) << "Got redundant documentLoaded from" << document->url() << textDocument;
return;
}
......
......@@ -171,8 +171,9 @@ TopDUContext::Features ParseJob::staticMinimumFeatures(const IndexedString& url)
QMutexLocker lock(&minimumFeaturesMutex);
auto features = ( TopDUContext::Features )0;
if (::staticMinimumFeatures.contains(url))
foreach (const TopDUContext::Features f, ::staticMinimumFeatures[url])
const auto featuresIt = ::staticMinimumFeatures.constFind(url);
if (featuresIt != ::staticMinimumFeatures.constEnd())
for (const TopDUContext::Features f : *featuresIt)
features = ( TopDUContext::Features )(features | f);
return features;
......
......@@ -139,22 +139,24 @@ void ParseProjectJob::start()
if (auto currentDocument = ICore::self()->documentController()->activeDocument()) {
const auto path = IndexedString(currentDocument->url());
if (d->filesToParse.contains(path)) {
auto fileIt = d->filesToParse.find(path);
if (fileIt != d->filesToParse.end()) {
ICore::self()->languageController()->backgroundParser()->addDocument(path,
TopDUContext::AllDeclarationsContextsAndUses, BackgroundParser::BestPriority,
this);
d->filesToParse.remove(path);
d->filesToParse.erase(fileIt);
}
}
// Add all currently open files that belong to the project to the background-parser, so that they'll be parsed first of all
foreach (auto document, ICore::self()->documentController()->openDocuments()) {
const auto path = IndexedString(document->url());
if (d->filesToParse.contains(path)) {
auto fileIt = d->filesToParse.find(path);
if (fileIt != d->filesToParse.end()) {
ICore::self()->languageController()->backgroundParser()->addDocument(path,
TopDUContext::AllDeclarationsContextsAndUses, 10,
this);
d->filesToParse.remove(path);
d->filesToParse.erase(fileIt);
}
}
......
......@@ -167,8 +167,9 @@ bool ClassNode::updateClassDeclarations()
continue;
// Don't add existing declarations.
if (existingIdentifiers.contains(decl->ownIndex())) {
existingIdentifiers.remove(decl->ownIndex());
const auto identifierIt = existingIdentifiers.find(decl->ownIndex());
if (identifierIt != existingIdentifiers.end()) {
existingIdentifiers.erase(identifierIt);
continue;
}
......
......@@ -253,9 +253,10 @@ bool DocumentClassesFolder::updateDocument(const KDevelop::IndexedString& a_file
continue;
// Is this a new class or an existing class?
if (removedClasses.contains(id)) {
const auto classIt = removedClasses.find(id);
if (classIt != removedClasses.end()) {
// It already exist - remove it from the known classes and continue.
removedClasses.remove(id);
removedClasses.erase(classIt);
continue;
}
......
......@@ -324,13 +324,15 @@ static QHash<IndexedString, QExplicitlySharedDataPointer<ArtificialStringData>>
//Return the representation for the given URL if it exists, or an empty pointer otherwise
static QExplicitlySharedDataPointer<ArtificialStringData> representationForPath(const IndexedString& path)
{
if (artificialStrings.contains(path))
return artificialStrings[path];
const auto artificialStringIt = artificialStrings.constFind(path);
if (artificialStringIt != artificialStrings.constEnd())
return *artificialStringIt;
else
{
IndexedString constructedPath(CodeRepresentation::artificialPath(path.str()));
if (artificialStrings.contains(constructedPath))
return artificialStrings[constructedPath];
const auto artificialStringIt = artificialStrings.constFind(constructedPath);
if (artificialStringIt != artificialStrings.constEnd())
return *artificialStringIt;
else
return QExplicitlySharedDataPointer<ArtificialStringData>();
}
......
......@@ -421,11 +421,12 @@ public:
{
QMutexLocker l(&m_referenceCountsMutex);
if (m_referenceCounts.contains(context)) {
auto countIt = m_referenceCounts.constFind(context);
if (countIt != m_referenceCounts.constEnd()) {
//This happens during shutdown, since everything is unloaded
qCDebug(LANGUAGE) << "removed a top-context that was reference-counted:" << context->url().str() <<
context->ownIndex();
m_referenceCounts.remove(context);
m_referenceCounts.erase(countIt);
}
}
......
......@@ -176,10 +176,11 @@ void AbstractNavigationContext::clear()
void AbstractNavigationContext::executeLink(const QString& link)
{
if (!d->m_links.contains(link))
const auto actionIt = d->m_links.constFind(link);
if (actionIt == d->m_links.constEnd())
return;
execute(d->m_links[link]);
execute(*actionIt);
}
NavigationContextPointer AbstractNavigationContext::executeKeyAction(const QString& key)
......@@ -442,12 +443,13 @@ NavigationContextPointer AbstractNavigationContext::accept(IndexedDeclaration de
NavigationContextPointer AbstractNavigationContext::acceptLink(const QString& link)
{
if (!d->m_links.contains(link)) {
const auto actionIt = d->m_links.constFind(link);
if (actionIt == d->m_links.constEnd()) {
qCDebug(LANGUAGE) << "Executed unregistered link " << link << endl;
return NavigationContextPointer(this);
}
return execute(d->m_links[link]);
return execute(*actionIt);
}
NavigationAction AbstractNavigationContext::currentAction() const
......
......@@ -250,7 +250,8 @@ public:
QHash<const TopDUContext*, QPair<int, const TopDUContext*>> b = context->m_local->m_recursiveImports;
for (RecursiveImports::const_iterator it = b.constBegin(); it != b.constEnd(); ++it) {
if (m_recursiveImports.contains(it.key()) && m_recursiveImports[it.key()].second == context)
const auto recursiveImportIt = m_recursiveImports.constFind(it.key());
if (recursiveImportIt != m_recursiveImports.constEnd() && recursiveImportIt->second == context)
removeImportedContextRecursion(context, it.key(), it->first + 1, rebuild); //Remove all contexts that are imported through the context
}
}
......
......@@ -154,7 +154,8 @@ bool CodeHighlighting::hasHighlighting(IndexedString url) const
DocumentChangeTracker* tracker = ICore::self()->languageController()->backgroundParser()->trackerForUrl(url);
if (tracker) {
QMutexLocker lock(&m_dataMutex);
return m_highlights.contains(tracker) && !m_highlights[tracker]->m_highlightedRanges.isEmpty();
const auto highlightingIt = m_highlights.constFind(tracker);
return highlightingIt != m_highlights.constEnd() && !(*highlightingIt)->m_highlightedRanges.isEmpty();
}
return false;
}
......@@ -234,10 +235,12 @@ void CodeHighlightingInstance::highlightDUChain(DUContext* context, QHash<Declar
(imported.context(top)->type() != DUContext::Other && imported.context(top)->type() != DUContext::Function))
continue;
//For now it's enough simply copying them, because we only pass on colors within function bodies.
if (m_functionColorsForDeclarations.contains(imported.context(top)))
colorsForDeclarations = m_functionColorsForDeclarations[imported.context(top)];
if (m_functionDeclarationsForColors.contains(imported.context(top)))
declarationsForColors = m_functionDeclarationsForColors[imported.context(top)];
const auto functionColorsIt = m_functionColorsForDeclarations.constFind(imported.context(top));
if (functionColorsIt != m_functionColorsForDeclarations.constEnd())
colorsForDeclarations = *functionColorsIt;
const auto functionDeclarationsIt = m_functionDeclarationsForColors.constFind(imported.context(top));
if (functionDeclarationsIt != m_functionDeclarationsForColors.constEnd())
declarationsForColors = *functionDeclarationsIt;
}
QList<Declaration*> takeFreeColors;
......@@ -300,8 +303,9 @@ void CodeHighlightingInstance::highlightDUChain(DUContext* context, QHash<Declar
for (int a = 0; a < context->usesCount(); ++a) {
Declaration* decl = context->topContext()->usedDeclarationForIndex(context->uses()[a].m_declarationIndex);
QColor color(QColor::Invalid);
if (colorsForDeclarations.contains(decl))
color = ColorCache::self()->generatedColor(colorsForDeclarations[decl]);
const auto colorsIt = colorsForDeclarations.constFind(decl);
if (colorsIt != colorsForDeclarations.constEnd())
color = ColorCache::self()->generatedColor(*colorsIt);
highlightUse(context, a, color);
}
......@@ -338,8 +342,9 @@ KDevelop::Declaration* CodeHighlightingInstance::localClassFromCodeContext(KDeve
if (!context)
return nullptr;
if (m_contextClasses.contains(context))
return m_contextClasses[context];
const auto classIt = m_contextClasses.constFind(context);
if (classIt != m_contextClasses.constEnd())
return *classIt;
DUContext* startContext = context;
......@@ -356,8 +361,9 @@ KDevelop::Declaration* CodeHighlightingInstance::localClassFromCodeContext(KDeve
Declaration* functionDeclaration = nullptr;
if (auto* def = dynamic_cast<FunctionDefinition*>(context->owner())) {
if (m_contextClasses.contains(context))
return m_contextClasses[context];
const auto classIt = m_contextClasses.constFind(context);
if (classIt != m_contextClasses.constEnd())
return *classIt;
functionDeclaration = def->declaration(startContext->topContext());
}
......@@ -497,11 +503,13 @@ void CodeHighlighting::clearHighlightingForDocument(const IndexedString& documen
VERIFY_FOREGROUND_LOCKED
QMutexLocker lock(&m_dataMutex);
DocumentChangeTracker* tracker = ICore::self()->languageController()->backgroundParser()->trackerForUrl(document);
if (m_highlights.contains(tracker)) {
auto highlightingIt = m_highlights.find(tracker);
if (highlightingIt != m_highlights.end()) {
disconnect(tracker, &DocumentChangeTracker::destroyed, this, &CodeHighlighting::trackerDestroyed);
qDeleteAll(m_highlights[tracker]->m_highlightedRanges);
delete m_highlights[tracker];
m_highlights.remove(tracker);
auto& highlighting = *highlightingIt;
qDeleteAll(highlighting->m_highlightedRanges);
delete highlighting;
m_highlights.erase(highlightingIt);
}
}
......@@ -530,9 +538,11 @@ void CodeHighlighting::applyHighlighting(void* _highlighting)
QVector<MovingRange*> oldHighlightedRanges;
if (m_highlights.contains(tracker)) {
oldHighlightedRanges = m_highlights[tracker]->m_highlightedRanges;
delete m_highlights[tracker];
const auto highlightingIt = m_highlights.find(tracker);
if (highlightingIt != m_highlights.end()) {
oldHighlightedRanges = (*highlightingIt)->m_highlightedRanges;
delete *highlightingIt;
*highlightingIt = highlighting;
} else {
// we newly add this tracker, so add the connection
// This can't use new style connect syntax since MovingInterface is not a QObject
......@@ -541,10 +551,9 @@ void CodeHighlighting::applyHighlighting(void* _highlighting)
connect(tracker->document(), SIGNAL(aboutToRemoveText(KTextEditor::Range)),
this, SLOT(aboutToRemoveText(KTextEditor::Range)));
connect(tracker, &DocumentChangeTracker::destroyed, this, &CodeHighlighting::trackerDestroyed);
m_highlights.insert(tracker, highlighting);
}
m_highlights[tracker] = highlighting;
// Now create MovingRanges (match old ones with the incoming ranges)
KTextEditor::Range tempRange;
......@@ -620,8 +629,9 @@ void CodeHighlighting::aboutToRemoveText(const KTextEditor::Range& range)
DocumentChangeTracker* tracker = ICore::self()->languageController()->backgroundParser()
->trackerForUrl(IndexedString(doc->url()));
if (m_highlights.contains(tracker)) {
QVector<MovingRange*>& ranges = m_highlights.value(tracker)->m_highlightedRanges;
const auto highlightingIt = m_highlights.constFind(tracker);
if (highlightingIt != m_highlights.constEnd()) {
QVector<MovingRange*>& ranges = (*highlightingIt)->m_highlightedRanges;
QVector<MovingRange*>::iterator it = ranges.begin();
while (it != ranges.end()) {
if (range.contains((*it)->toRange())) {
......
......@@ -111,10 +111,11 @@ public:
void AbstractFileManagerPluginPrivate::projectClosing(IProject* project)
{
if ( m_projectJobs.contains(project) ) {
const auto projectJobIt = m_projectJobs.constFind(project);
if (projectJobIt != m_projectJobs.constEnd()) {
// make sure the import job does not live longer than the project
// see also addLotsOfFiles test
foreach( FileManagerListJob* job, m_projectJobs[project] ) {
for (FileManagerListJob* job : *projectJobIt) {
qCDebug(FILEMANAGER) << "killing project job:" << job;
job->abort();
}
......
......@@ -185,9 +185,11 @@ QMutex& ItemRepositoryRegistry::mutex()
QAtomicInt& ItemRepositoryRegistry::customCounter(const QString& identity, int initialValue)
{
if (!d->m_customCounters.contains(identity))
d->m_customCounters.insert(identity, new QAtomicInt(initialValue));
return *d->m_customCounters[identity];
auto customCounterIt = d->m_customCounters.find(identity);
if (customCounterIt == d->m_customCounters.end()) {
customCounterIt = d->m_customCounters.insert(identity, new QAtomicInt(initialValue));
}
return **customCounterIt;
}
///The global item-repository registry that is used by default
......
......@@ -159,9 +159,10 @@ public:
QMutableHashIterator<QUrl, IDocument*> it = documents;
while (it.hasNext()) {
if (it.next().value() == document) {
if (documents.contains(document->url())) {
const auto documentIt = documents.constFind(document->url());
if (documentIt != documents.constEnd()) {
// Weird situation (saving as a file that is aready open)
IDocument* origDoc = documents[document->url()];
IDocument* origDoc = *documentIt;
if (origDoc->state() & IDocument::Modified) {
// given that the file has been saved, close the saved file as the other instance will become conflicted on disk
document->close();
......@@ -711,13 +712,14 @@ void DocumentController::fileClose()
bool DocumentController::closeDocument( const QUrl &url )
{
if( !d->documents.contains(url) )
const auto documentIt = d->documents.constFind(url);
if (documentIt == d->documents.constEnd())
return false;
//this will remove all views and after the last view is removed, the
//document will be self-destructed and removeDocument() slot will catch that
//and clean up internal data structures
d->documents[url]->close();
(*documentIt)->close();
return true;
}
......
......@@ -201,8 +201,9 @@ ILanguageSupport* LanguageController::language(const QString &name) const
if(d->m_cleanedUp)
return nullptr;
if(d->languages.contains(name))
return d->languages[name];
const auto languageIt = d->languages.constFind(name);
if (languageIt != d->languages.constEnd())
return *languageIt;
// temporary support for deprecated-in-5.1 "X-KDevelop-Language" as fallback
// remove in later version
......
......@@ -300,8 +300,9 @@ void MainWindow::configureShortcuts()
foreach(KXMLGUIClient* client, Core::self()->uiControllerInternal()->mainWindows()[a]->guiFactory()->clients()) {
foreach(QAction* action, client->actionCollection()->actions()) {
qCDebug(SHELL) << "transferring setting shortcut for" << action->objectName();
if(shortcuts.contains(action->objectName())) {
action->setShortcut(shortcuts[action->objectName()]);
const auto shortcutIt = shortcuts.constFind(action->objectName());
if (shortcutIt != shortcuts.constEnd()) {
action->setShortcut(*shortcutIt);
}
}
}
......
......@@ -291,8 +291,9 @@ ProgressDialog::~ProgressDialog()
void ProgressDialog::slotTransactionAdded( ProgressItem *item )
{
if ( item->parent() ) {
if ( mTransactionsToListviewItems.contains( item->parent() ) ) {
TransactionItem * parent = mTransactionsToListviewItems[ item->parent() ];
const auto parentItemIt = mTransactionsToListviewItems.constFind(item->parent());
if (parentItemIt != mTransactionsToListviewItems.constEnd()) {
TransactionItem* parent = *parentItemIt;
parent->addSubTransaction( item );
}
} else {
......@@ -310,9 +311,10 @@ void ProgressDialog::slotTransactionAdded( ProgressItem *item )
void ProgressDialog::slotTransactionCompleted( ProgressItem *item )
{
if ( mTransactionsToListviewItems.contains( item ) ) {
TransactionItem *ti = mTransactionsToListviewItems[ item ];
mTransactionsToListviewItems.remove( item );
const auto itemIt = mTransactionsToListviewItems.find(item);
if (itemIt != mTransactionsToListviewItems.end()) {
TransactionItem* ti = *itemIt;
mTransactionsToListviewItems.erase(itemIt);
ti->setItemComplete();
QTimer::singleShot( 3000, mScrollView, [=] { mScrollView->slotItemCompleted(ti); } );
}
......@@ -329,8 +331,9 @@ void ProgressDialog::slotTransactionCanceled( ProgressItem * )
void ProgressDialog::slotTransactionProgress( ProgressItem *item,
unsigned int progress )
{
if ( mTransactionsToListviewItems.contains( item ) ) {
TransactionItem *ti = mTransactionsToListviewItems[ item ];
const auto itemIt = mTransactionsToListviewItems.constFind(item);
if (itemIt != mTransactionsToListviewItems.constEnd()) {
TransactionItem* ti = *itemIt;
ti->setProgress( progress );
}
}
......@@ -338,8 +341,9 @@ void ProgressDialog::slotTransactionProgress( ProgressItem *item,
void ProgressDialog::slotTransactionStatus( ProgressItem *item,
const QString &status )
{
if ( mTransactionsToListviewItems.contains( item ) ) {
TransactionItem *ti = mTransactionsToListviewItems[ item ];
const auto itemIt = mTransactionsToListviewItems.constFind(item);
if (itemIt != mTransactionsToListviewItems.constEnd()) {
TransactionItem* ti = *itemIt;
ti->setStatus( status );
}
}
......@@ -347,16 +351,18 @@ void ProgressDialog::slotTransactionStatus( ProgressItem *item,
void ProgressDialog::slotTransactionLabel( ProgressItem *item,
const QString &label )
{
if ( mTransactionsToListviewItems.contains( item ) ) {
TransactionItem *ti = mTransactionsToListviewItems[ item ];
const auto itemIt = mTransactionsToListviewItems.constFind(item);
if (itemIt != mTransactionsToListviewItems.constEnd()) {
TransactionItem* ti = *itemIt;
ti->setLabel( label );
}
}
void ProgressDialog::slotTransactionUsesBusyIndicator( KDevelop::ProgressItem *item, bool value )
{
if ( mTransactionsToListviewItems.contains( item ) ) {
TransactionItem *ti = mTransactionsToListviewItems[ item ];
const auto itemIt = mTransactionsToListviewItems.constFind(item);
if (itemIt != mTransactionsToListviewItems.constEnd()) {
TransactionItem* ti = *itemIt;
if ( value ) {
ti->setTotalSteps( 0 );
} else {
......
......@@ -270,8 +270,9 @@ KConfigGroup SourceFormatterController::globalConfig() const
ISourceFormatter* SourceFormatterController::findFirstFormatterForMimeType(const QMimeType& mime ) const
{
static QHash<QString, ISourceFormatter*> knownFormatters;
if (knownFormatters.contains(mime.name()))
return knownFormatters[mime.name()];
const auto formatterIt = knownFormatters.constFind(mime.name());
if (formatterIt != knownFormatters.constEnd())
return *formatterIt;
foreach (ISourceFormatter* iformatter, d->sourceFormatters) {
QSharedPointer<SourceFormatter> formatter(createFormatterForPlugin(iformatter));
......
......@@ -203,16 +203,18 @@ void StatusBar::updateMessage()
void StatusBar::clearMessage( IStatus* status )
{
if (m_messages.contains(status)) {
m_messages.remove(status);
const auto messageIt = m_messages.find(status);
if (messageIt != m_messages.end()) {
m_messages.erase(messageIt);
updateMessage();
}
}
void StatusBar::showMessage( IStatus* status, const QString & message, int timeout)
{
if ( m_progressItems.contains(status) ) {
ProgressItem* i = m_progressItems[status];
const auto progressItemIt = m_progressItems.constFind(status);
if (progressItemIt != m_progressItems.constEnd()) {
ProgressItem* i = *progressItemIt;
i->setStatus(message);
} else {
Message m;
......@@ -225,22 +227,23 @@ void StatusBar::showMessage( IStatus* status, const QString & message, int timeo
void StatusBar::hideProgress( IStatus* status )
{
if (m_progressItems.contains(status)) {
m_progressItems[status]->setComplete();
m_progressItems.remove(status);
}
const auto progressItemIt = m_progressItems.find(status);
if (progressItemIt != m_progressItems.end()) {
(*progressItemIt)->setComplete();
m_progressItems.erase(progressItemIt);
}
}
void StatusBar::showProgress( IStatus* status, int minimum, int maximum, int value)
{
if (!m_progressItems.contains(status)) {
auto progressItemIt = m_progressItems.find(status);
if (progressItemIt == m_progressItems.end()) {
bool canBeCanceled = false;
m_progressItems