Merge lp:~stolowski/unity8/results-nullptr-fix into lp:unity8

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 339
Merged at revision: 340
Proposed branch: lp:~stolowski/unity8/results-nullptr-fix
Merge into: lp:unity8
Diff against target: 30 lines (+12/-1)
1 file modified
plugins/Unity/categories.cpp (+12/-1)
To merge this branch: bzr merge lp:~stolowski/unity8/results-nullptr-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michal Hruby (community) Approve
Review via email: mp+187052@code.launchpad.net

Commit message

Check results model ptr returned by GetResultsFromCategory method from UnityCore.

Description of the change

Check results model ptr returned by GetResultsFromCategory method from UnityCore against nullptr, as it may be null in some cases (namely before channel is opened). If this happens, don't use it to set DeeListModel and just use an empty DeeListModel; it will be set properly when both categories and results models are set on channel opening in UnityCore.

To post a comment you must log in.
337. By Paweł Stołowski

Fixed type in variable name.

Revision history for this message
Michal Hruby (mhr3) wrote :

17 + if (unity_results) {
18 + results->setModel(unity_results->model());
19 + } else {

The else branch should call setModel(NULL), although I'm not sure what to do about the cached value in that case.

49 + m_resultshangedConnection.disconnect();
50 + m_resultshangedConnection = m_unityScope->results()->model.changed.connect(sigc::mem_fun(this, &Categories::onScopeResultsModelChanged));

I specifically didn't want that signal, cause now we end up setting the model multiple times.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

> 17 + if (unity_results) {
> 18 + results->setModel(unity_results->model());
> 19 + } else {
>
> The else branch should call setModel(NULL), although I'm not sure what to do
> about the cached value in that case.
Why explicit setModel(NULL)? We are dealing with new CategoryResults object here, the model is NULL. As for cached results, I expect we will be notifed by signal, and onCategoriesModelChanged will reset all categories?

>
> 49 + m_resultshangedConnection.disconnect();
> 50 + m_resultshangedConnection =
> m_unityScope->results()->model.changed.connect(sigc::mem_fun(this,
> &Categories::onScopeResultsModelChanged));
>
> I specifically didn't want that signal, cause now we end up setting the model
> multiple times
Right. I think it's safe to assume (after looking into UnityCore - ScopeProxy.cpp) that categories changed signal is enough, since both category and results models are set under the same circumstances - on channel opening. Will remove it.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:337
http://jenkins.qa.ubuntu.com/job/unity8-ci/1069/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/3853
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/1381
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/1800
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/93
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1070
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1070/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1069
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/193
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3865
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3865/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1383
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1383/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/1166
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/1177

Click here to trigger a rebuild:
http://s-jenkins:8080/job/unity8-ci/1069/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:337
http://jenkins.qa.ubuntu.com/job/unity8-ci/1073/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/3872
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/1411
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/1807
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/97
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1074
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1074/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1073
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/208
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3895
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3895/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1413
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1413/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/1191
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/1202

Click here to trigger a rebuild:
http://s-jenkins:8080/job/unity8-ci/1073/rebuild

review: Approve (continuous-integration)
338. By Paweł Stołowski

Don't connect to results model change signal.

Revision history for this message
Michal Hruby (mhr3) wrote :

36 +void Categories::onScopeResultsModelChanged(unity::glib::Object<DeeModel> /* model */)
37 +{
38 + // if scope results model changes, we need to reset all category models
39 + onCategoriesModelChanged(m_unityScope->categories()->model());
40 +}

If it's no longer connected shouldn't it go away?

53 + void onScopeResultsModelChanged(unity::glib::Object<DeeModel> model);

ditto

Why explicit setModel(NULL)? We are dealing with new CategoryResults object here, the model is NULL. As for cached results, I expect we will be notifed by signal, and onCategoriesModelChanged will reset all categories?

If setModel(NULL) is not called, the UI will keep displaying the old model (do we want that?), if it is, it will behave the same way as if an empty model was present (but won't react to searches).

339. By Paweł Stołowski

Removed unused signal handler.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:338
http://jenkins.qa.ubuntu.com/job/unity8-ci/1086/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/3903
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/1473
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/1825
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/110
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1087
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1087/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1086
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/234
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3957
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3957/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1475
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1475/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/1242
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/1253

Click here to trigger a rebuild:
http://s-jenkins:8080/job/unity8-ci/1086/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

Ah, ok the results instance is created just before the start of the diff.. so yea, no need for extra setModel(NULL);

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:339
http://jenkins.qa.ubuntu.com/job/unity8-ci/1087/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/3906
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/1477
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/1826
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/111
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1088
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1088/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1087
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/238
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3961
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/3961/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1479
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/1479/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/1247
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/1258

Click here to trigger a rebuild:
http://s-jenkins:8080/job/unity8-ci/1087/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/categories.cpp'
2--- plugins/Unity/categories.cpp 2013-09-02 11:21:46 +0000
3+++ plugins/Unity/categories.cpp 2013-09-24 09:29:45 +0000
4@@ -21,6 +21,7 @@
5 // self
6 #include "categories.h"
7 #include "categoryresults.h"
8+#include <QDebug>
9
10 // TODO: use something from libunity once it's public
11 enum CategoryColumn {
12@@ -62,7 +63,17 @@
13
14 unsigned categoryIndex = static_cast<unsigned>(index);
15 auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex);
16- results->setModel(unity_results->model());
17+ if (unity_results) {
18+ results->setModel(unity_results->model());
19+ } else {
20+ // No results model returned by unity core; this can be the case when the global
21+ // results model of this scope is still not set in unity core. Don't set backend
22+ // model in DeeListModel - it will still beahve properly as an empty model. Since
23+ // we're connected to the category model change signal, and it is set by unity core
24+ // at the same time as results model (on channel opening), we'll reset category
25+ // results models with proper models when we're notifed again.
26+ qWarning() << "No results model for category" << categoryIndex;
27+ }
28
29 m_results.insert(index, results);
30 }

Subscribers

People subscribed via source and target branches