36019 Commits

Author SHA1 Message Date
volaya
96b8a90758 [processing] In raster calculator, use filename without extension to refer to layer 2016-12-06 09:03:51 +01:00
volaya
ec8aea2f60 [processin] fixed wrong parameter type 2016-12-06 07:19:24 +01:00
Nyall Dawson
6f9292a75d Reenable all task manager tests 2016-12-06 14:22:03 +10:00
Nyall Dawson
7bbc60a135 Prevent closing QGIS while tasks are running 2016-12-06 09:23:41 +10:00
Nyall Dawson
008817b089 Fix ui build warnings 2016-12-06 08:18:19 +10:00
Alexander Bruy
62cb38153c [processing] prevent divizion by zero (fix #15825) 2016-12-05 20:14:29 +02:00
Alexander Bruy
2fea23f1e5 Merge pull request #3779 from volaya/rastercalculator
[processing] add native raster calculator
2016-12-05 20:03:23 +02:00
volaya
5c6c18caad [processing] fixed expected test hashes 2016-12-05 14:59:26 +01:00
Matthias Kuhn
abbe281bc7 Preprocess header file in sipdiff to reduce noise
and common sources of trouble.
2016-12-05 14:46:40 +01:00
volaya
b7daf9bca3 [processing] changed input type from vector layer to table for execute sql algorithm 2016-12-05 13:52:13 +01:00
volaya
16da906398 [processing] allow multiple selection of tables 2016-12-05 13:39:38 +01:00
nirvn
57d80a5a82 [style dock] avoid long labels in the point pattern fill UI 2016-12-05 17:05:00 +07:00
Alessandro Pasotti
3ec5f92f0f Replaced the expired SSL certificate and re-enabled OWS PKI test 2016-12-05 10:31:10 +01:00
Alessandro Pasotti
b92cf53cad Typo in comment 2016-12-05 10:31:10 +01:00
Hugo Mercier
89461909d3 [virtual layer] Fix xFilter for null value comparisons 2016-12-05 10:02:53 +01:00
Alexander Bruy
77bbeaa99f fix loading of models containing user-defined scripts 2016-12-05 10:31:38 +02:00
Nyall Dawson
b1b647349a Merge pull request #3004 from nyalldawson/task_manager
[FEATURE] Task manager
2016-12-05 17:47:38 +10:00
Nyall Dawson
cc702c9c81 Remove (probably unnecessary) copy_func usage 2016-12-05 16:46:10 +10:00
Nyall Dawson
d03d0a5b47 Add some python docstrings to QgsTask.fromFunction 2016-12-05 14:08:12 +10:00
Nyall Dawson
feb3219852 Update doxygen 2016-12-05 14:08:12 +10:00
Nyall Dawson
631d3cd998 Consolidate mutexes 2016-12-05 14:08:12 +10:00
Nyall Dawson
e35420a8d9 Force QgsTask::run() to fully complete
Remove support for signal based completion/termination

Also unfortunately disable a lot of the test suite as a result,
since it's not easily translatable
2016-12-05 14:08:12 +10:00
Nyall Dawson
268e5127f2 Make QgsTask::start private
Only allow starting tasks to be done by QgsTaskManager
2016-12-05 14:08:12 +10:00
Nyall Dawson
297b5724df QgsTask is no longer a QRunnable
Instead use a private wrapper class to make QgsTask compatible
with QThreadPool
2016-12-05 14:08:12 +10:00
Nyall Dawson
29f310c070 Convert QgsTask.fromFunction to a static method 2016-12-05 14:08:11 +10:00
Nyall Dawson
619381c0ad Call QgsTaskWrapper.on_finished with exception rather than result 2016-12-05 14:08:11 +10:00
Nyall Dawson
fded1a1f39 Don't explode returned values in QgsTaskWrapper
Breaks returning list values
2016-12-05 14:08:11 +10:00
Nyall Dawson
f73f3c14f5 Remove outdated flaky test ifdefs 2016-12-05 14:08:11 +10:00
Nyall Dawson
cd3269352b Nicer icons and ui for task status 2016-12-05 14:08:11 +10:00
Nyall Dawson
79beb54c53 Remove redundant member 2016-12-05 14:08:11 +10:00
Nyall Dawson
a24690d6db Task manager GUI cleanups 2016-12-05 14:08:11 +10:00
Nyall Dawson
0dcff4491e Respect QgsTask::CanCancel flag in gui 2016-12-05 14:08:11 +10:00
Nyall Dawson
466b0b96b7 Tasks are treated as progressless until they first report a progress 2016-12-05 14:08:11 +10:00
Nyall Dawson
4dc3dd9077 Allow task priority to be specified 2016-12-05 14:08:11 +10:00
Nyall Dawson
9b763741b8 QThreadPool::cancel was introduced in Qt5.5, so no cancellation
possible for Qt < 5.5

Moral of the story: if you run outdated libraries, you can't
expect full functionality from your apps ;)
2016-12-05 14:08:11 +10:00
Nyall Dawson
5216220872 Fix more racy conditions
Switch from QtConcurrent::run to QThreadPool::start

QtConcurrent doesn't give us anyway to cancel queued but not
started tasks. QThreadPool does (and also allows us to specify
task priority)
2016-12-05 14:08:11 +10:00
Nyall Dawson
01d6afaf2c Avoid recursive locks 2016-12-05 14:08:11 +10:00
Nyall Dawson
14b6b3f6ee Harden everything up
And finally fix a racy condition which has been plaguing me for
ages
2016-12-05 14:08:11 +10:00
Nyall Dawson
32a9e1e9d6 QgsTasks can have subtasks
Now, a QgsTask can have subtask QgsTasks set by calling
QgsTask::addSubTask. Sub tasks can have their own set of
dependent tasks.

Subtasks are not visible to users, and users only see the overall
progress and status of the parent task.

This allows creation of tasks which are themselves built off
many smaller component tasks. The task manager will still handle
firing up and scheduling the subtasks, so eg subtasks can run
in parallel (if their dependancies allow this).

Subtasks can themselves have subtasks.

This change is designed to allow the processing concept of
algorithms and modeller algorithms to be translatable
directly to the task manager architecture.
2016-12-05 14:08:11 +10:00
Nyall Dawson
3999a3710f Remove QgsTaskManager singleton, and instead attach an instance
to QgsApplication.

ie instead of QgsTaskManager.instance(), use
QgsApplication.taskManager()
2016-12-05 14:08:11 +10:00
Nyall Dawson
b6b7a7f8c6 Remove delete* methods from QgsTaskManager API
On further consideration allowing external control of task
deletion is a bad idea.
2016-12-05 14:08:11 +10:00
Nyall Dawson
ad71dc443d Fix failing tests 2016-12-05 14:08:11 +10:00
Nyall Dawson
6d4392a0f7 Allow QgsTask subclasses to defined a finished function, which is
called when the task has completed (successfully or otherwise).

This allows for simpler task design when the signal/slot
based approach is not required. Just implement run() with your
heavy lifting, and finished() to do whatever follow up stuff
should happen after the task is complete. finished is always
called from the main thread, so it's safe to do GUI operations
here.

Python based tasks using the simplified QgsTask.fromFunction
approach can now set a on_finished argument to a function
to call when the task is complete.

eg:

def calculate(task):
    # pretend this is some complex maths and stuff we want
    # to run in the background
    return 5*6

def calculation_finished(result, value=None):
    if result == QgsTask.ResultSuccess:
	iface.messageBar().pushMessage(
            'the magic number is {}'.format(value))
    elif result == QgsTask.ResultFail:
        iface.messageBar().pushMessage(
            'couldn\'t work it out, sorry')

task = QgsTask.fromFunction('my task', calculate,
		on_finished=calculation_finished)
QgsTaskManager.instance().addTask(task)

Multiple values can also be returned, eg:

def calculate(task):
    return (4, 8, 15)

def calculation_finished(result, count=None, max=None, sum=None):
    # here:
    # count = 4
    # max = 8
    # sum = 15

task = QgsTask.fromFunction('my task', calculate,
		on_finished=calculation_finished)
QgsTaskManager.instance().addTask(task)
2016-12-05 14:08:11 +10:00
Nyall Dawson
252f2e1102 Rename overloaded signal, flip remaining connects to new style 2016-12-05 14:08:11 +10:00
Nyall Dawson
f71c78e14f Rename stopped to terminated for consistency 2016-12-05 14:08:11 +10:00
Nyall Dawson
e01c306edb Simplify reporting completion of tasks
QgsTask subclasses can now return a result (success or fail)
directly from QgsTask::run. If they do so then there's no
need for them to manually call completed() or stopped()
to report their completion.

Alternatively, tasks can also return the ResultPending value
to indicate that the task is still operating and will
manually report its completion by calling completed() or
stopped(). This may be useful for tasks which rely on external
events for completion, eg downloading a file. In this case
Qt slots could be created which are connected to the download
completion or termination and which call completed() or
stopped() to indicate the task has finished operations.
2016-12-05 14:08:11 +10:00
Nyall Dawson
2590f685fe Documentation updates and small API cleanups 2016-12-05 14:08:11 +10:00
Nyall Dawson
bc37b40179 Smaller header updates, switch connect style 2016-12-05 14:08:11 +10:00
Nyall Dawson
95dbb3a7e3 Add deleteAllTasks to manager 2016-12-05 14:08:11 +10:00
Nyall Dawson
b64025df5c Add python test for task manager 2016-12-05 14:08:11 +10:00