Merge lp:~mc-return/compiz/compiz.merge-fix1101549-and-fix1101561-missing-break into lp:compiz/0.9.9

Proposed by MC Return
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 3586
Merged at revision: 3589
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1101549-and-fix1101561-missing-break
Merge into: lp:compiz/0.9.9
Diff against target: 19 lines (+3/-2)
1 file modified
plugins/annotate/src/annotate.cpp (+3/-2)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1101549-and-fix1101561-missing-break
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
MC Return Needs Information
PS Jenkins bot continuous-integration Pending
Review via email: mp+145161@code.launchpad.net

Commit message

Fixed the cases MotionNotify == EnterNotify == LeaveNotify
in the AnnoScreen::handleEvent (XEvent *event) function.
Do not call handleMotionEvent (pointerX, pointerY) twice.
Fall-through here is intentional.
Added missing break to not fall-through to default.
Fixed indentation.

(LP: #1101549, LP: #1101561)

Description of the change

Note:
This fix has been tested and the test revealed no obvious changes in the behaviour
of Annotate.
There is still some flickering going on, during drawing of rectangle or ellipse, see
bug 1107818, this still has to be fixed. This did not regress with this MP, but was
there before.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

4 @@ -964,9 +964,12 @@
5 switch (event->type) {
6 case MotionNotify:
7 handleMotionEvent (pointerX, pointerY);
8 + break;
9 case EnterNotify:
10 + break;
11 case LeaveNotify:
12 handleMotionEvent (pointerX, pointerY);
13 + break;
14 default:

Ouch, an intended fall through caught by coverity as a false positive. I knew this would eventually happen.

Unfortunately this is currently broken (in a very small way). pointerX and pointerY are updated on enter leave and motion events however this code only handles the change on motion and leave.

I think coverity won't complain if you do this:

case EnterNotify:
case LeaveNotify:
case MotionNotify:
    handleMotionEvent (pointerX, pointerY);
    break;

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote :

> 4 @@ -964,9 +964,12 @@
> 5 switch (event->type) {
> 6 case MotionNotify:
> 7 handleMotionEvent (pointerX, pointerY);
> 8 + break;
> 9 case EnterNotify:
> 10 + break;
> 11 case LeaveNotify:
> 12 handleMotionEvent (pointerX, pointerY);
> 13 + break;
> 14 default:
>
> Ouch, an intended fall through caught by coverity as a false positive. I knew
> this would eventually happen.
>
> Unfortunately this is currently broken (in a very small way). pointerX and
> pointerY are updated on enter leave and motion events however this code only
> handles the change on motion and leave.
>
> I think coverity won't complain if you do this:
>
> case EnterNotify:
> case LeaveNotify:
> case MotionNotify:
> handleMotionEvent (pointerX, pointerY);
> break;

Should it fall through to default as well or not ?
If not (which was the case previously) the last break
below handleMotionEvent (pointerX, pointerY); should
also be removed...

review: Needs Information
Revision history for this message
MC Return (mc-return) wrote :

Sam, default is this (if you do not have the code right now):

    default:
 if (event->type == cScreen->damageEvent () + XDamageNotify)
 {
     XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
     if (pixmap == de->drawable)
  cScreen->damageRegion (CompRegion (CompRect (de->area)));
 }
 break;
    }

3586. By MC Return

Fall-through is intentional here:
case MotionNotify == EnterNotify == LeaveNotify

Fixed indentation

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Yep, you've got the right implementation.

Generally a fallthough to damage handling through default: is harmless, but putting the break statement there will make coverity shut up, which is probably a good thing.

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

> Yep, you've got the right implementation.
>
> Generally a fallthough to damage handling through default: is harmless, but
> putting the break statement there will make coverity shut up, which is
> probably a good thing.

Oh, great. Thx 4 the review & the information :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/annotate/src/annotate.cpp'
2--- plugins/annotate/src/annotate.cpp 2012-09-04 15:33:44 +0000
3+++ plugins/annotate/src/annotate.cpp 2013-01-28 13:48:20 +0000
4@@ -961,12 +961,13 @@
5 void
6 AnnoScreen::handleEvent (XEvent *event)
7 {
8- switch (event->type) {
9+ switch (event->type)
10+ {
11 case MotionNotify:
12- handleMotionEvent (pointerX, pointerY);
13 case EnterNotify:
14 case LeaveNotify:
15 handleMotionEvent (pointerX, pointerY);
16+ break;
17 default:
18 if (event->type == cScreen->damageEvent () + XDamageNotify)
19 {

Subscribers

People subscribed via source and target branches