Merge lp:~mkhu/compiz/compiz_fix_put_to_arbitrary_viewport into lp:compiz/0.9.9

Proposed by Micheal Hsu
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3638
Merged at revision: 3638
Proposed branch: lp:~mkhu/compiz/compiz_fix_put_to_arbitrary_viewport
Merge into: lp:compiz/0.9.9
Diff against target: 26 lines (+12/-4)
1 file modified
plugins/put/src/put.cpp (+12/-4)
To merge this branch: bzr merge lp:~mkhu/compiz/compiz_fix_put_to_arbitrary_viewport
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sam Spilsbury Approve
Review via email: mp+155659@code.launchpad.net

Commit message

put: Don't resize the option vector every time PutScreen::toViewport is called - this will leave stale values in the option vector. Instead, check if the option exists already and resize the vector that.

(LP: #1160710)

Description of the change

in put.cpp:

bool PutScreen::toViewport (....)

the function resized the CompOption every time it's called.(this can cause memory leak).
subsequent calls to getIntOptionNamed(..) always return the first "viewport" value instead of of the correct value, which is appended to the tail of the vector.
the correct way is to find the "viewport" option and then set its value.

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

Yep, this makes sense. Thanks for that.

Did you see any other plugins which had similar behaviour? Might be good to get them fixed first.

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

> Yep, this makes sense. Thanks for that.
>
> Did you see any other plugins which had similar behaviour? Might be good to
> get them fixed first.

*Fixed too.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
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/put/src/put.cpp'
2--- plugins/put/src/put.cpp 2012-09-05 16:42:03 +0000
3+++ plugins/put/src/put.cpp 2013-03-27 05:26:18 +0000
4@@ -1181,10 +1181,18 @@
5 CompOption::Vector &option,
6 int vp)
7 {
8- int last = option.size ();
9- option.resize(last+1);
10- option[last].setName ("viewport",CompOption::TypeInt);
11- option[last].value ().set (vp-1);
12+ unsigned int index;
13+ if (CompOption::findOption (option, "viewport", &index) == NULL)
14+ {
15+ int last = option.size ();
16+ option.resize(last+1);
17+ option[last].setName ("viewport",CompOption::TypeInt);
18+ option[last].value ().set (vp-1);
19+ }
20+ else
21+ {
22+ option[index].value ().set (vp-1);
23+ }
24
25 return initiateCommon (action, state, option, (PutType) PutViewport);
26 }

Subscribers

People subscribed via source and target branches