Skip to content

Commit 44df58e

Browse files
committedFeb 12, 2018
Simplify code
1 parent 7609ab7 commit 44df58e

File tree

4 files changed

+10
-24
lines changed

4 files changed

+10
-24
lines changed
 

‎python/core/locator/qgslocatorfilter.sip.in

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,6 @@ Prepares the filter instance for an upcoming search for the specified ``string``
132132
from the main thread, and individual filter subclasses should perform whatever
133133
tasks are required in order to allow a subsequent search to safely execute
134134
on a background thread.
135-
%End
136-
137-
void executeSearchAndDelete( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback );
138-
%Docstring
139-
Executes a search for this filter instance, and then deletes the current instance
140-
of the filter.
141135
%End
142136

143137
virtual void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) = 0;
@@ -152,6 +146,9 @@ signal whenever they encounter a matching result.
152146
Subclasses should periodically check the ``feedback`` object to determine
153147
whether the query has been canceled. If so, the subclass should return
154148
from this method as soon as possible.
149+
150+
This will be called from a background thread unless flags() returns the
151+
QgsLocatorFilter.FlagFast flag.
155152
%End
156153

157154
virtual void triggerResult( const QgsLocatorResult &result ) = 0;

‎src/core/locator/qgslocator.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,11 @@ void QgsLocator::fetchResults( const QString &string, const QgsLocatorContext &c
152152
filter->moveToThread( thread );
153153
connect( thread, &QThread::started, filter, [filter, searchString, context, feedback]
154154
{
155-
filter->executeSearchAndDelete( searchString, context, feedback );
155+
if ( !feedback->isCanceled() )
156+
filter->fetchResults( searchString, context, feedback );
157+
filter->emit finished();
156158
}, Qt::QueuedConnection );
157-
connect( filter, &QgsLocatorFilter::finished, thread, [thread]
158-
{
159-
thread->quit();
160-
} );
159+
connect( filter, &QgsLocatorFilter::finished, thread, &QThread::quit );
161160
connect( filter, &QgsLocatorFilter::finished, filter, &QgsLocatorFilter::deleteLater );
162161
connect( thread, &QThread::finished, thread, [this, thread]
163162
{

‎src/core/locator/qgslocatorfilter.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ QgsLocatorFilter::Flags QgsLocatorFilter::flags() const
3232
return nullptr;
3333
}
3434

35-
void QgsLocatorFilter::executeSearchAndDelete( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback )
36-
{
37-
if ( !feedback->isCanceled() )
38-
fetchResults( string, context, feedback );
39-
emit finished();
40-
}
41-
4235
bool QgsLocatorFilter::stringMatches( const QString &candidate, const QString &search )
4336
{
4437
return candidate.contains( search, Qt::CaseInsensitive );

‎src/core/locator/qgslocatorfilter.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ class CORE_EXPORT QgsLocatorFilter : public QObject
165165
*/
166166
virtual void prepare( const QString &string, const QgsLocatorContext &context ) { Q_UNUSED( string ); Q_UNUSED( context ); }
167167

168-
/**
169-
* Executes a search for this filter instance, and then deletes the current instance
170-
* of the filter.
171-
*/
172-
void executeSearchAndDelete( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback );
173-
174168
/**
175169
* Retrieves the filter results for a specified search \a string. The \a context
176170
* argument encapsulates the context relating to the search (such as a map
@@ -182,6 +176,9 @@ class CORE_EXPORT QgsLocatorFilter : public QObject
182176
* Subclasses should periodically check the \a feedback object to determine
183177
* whether the query has been canceled. If so, the subclass should return
184178
* from this method as soon as possible.
179+
*
180+
* This will be called from a background thread unless flags() returns the
181+
* QgsLocatorFilter::FlagFast flag.
185182
*/
186183
virtual void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) = 0;
187184

0 commit comments

Comments
 (0)
Please sign in to comment.