qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] ui/cocoa.m: add Speed menu


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v3] ui/cocoa.m: add Speed menu
Date: Fri, 23 Jun 2017 15:03:11 +0100

On 21 June 2017 at 16:19, Peter Maydell <address@hidden> wrote:
> On 14 June 2017 at 04:17, Programmingkid <address@hidden> wrote:
>> Programs running inside of QEMU can sometimes use more CPU time than is 
>> really
>> needed. To solve this problem, we just need to throttle the virtual CPU. This
>> feature will stop laptops from burning up.
>>
>> This patch adds a menu called Speed that has menu items from 100% to 1% that
>> represent the speed options. 100% is full speed and 1% is slowest.
>>
>> Signed-off-by: John Arbuckle <address@hidden>
>> ---
>> v3 changes:
>> Changed the item deselection loop.
>> Moved speed calculation equation to main function.
>> Replaced "%c" with "%%".
>> Changed how 100% menu item is made.
>>
>> v2 changes:
>> Fixed missing space with 'if' and 'for' structures.
>> Fixed tab damage.
>> Use loop to create menu items.
>> Changed name of menu items to use percentages.
>> Use tags to determine selected menu item.
>
>> +    // Add the rest of the Speed menu items
>> +    int p, percentage, throttle_pct;
>> +    for (p = 10; p >= 0; p--)
>> +    {
>> +        percentage = p * 10 > 1 ? p * 10 : 1; // prevent a 0% menu item
>> +
>> +        if (percentage == 100) {
>> +            [menuItem setState: NSOnState];
>> +        }
>> +        menuItem = [[[NSMenuItem alloc]
>> +                   initWithTitle: [NSString stringWithFormat: @"%d%%", 
>> percentage] action:@selector(adjustSpeed:) keyEquivalent:@""] autorelease];
>
> Here you try to call setState: on the menuItem before
> you allocate it -- these lines should be the other way
> around. (The effect is that the 100% item isn't ticked
> on startup.)
>
>> +
>> +        /* Calculate the throttle percentage */
>> +        throttle_pct = -1 * percentage + 100;
>> +
>> +        [menuItem setTag: throttle_pct];
>> +        [menu addItem: menuItem];
>> +    }
>
> That's a very minor fix, so I'll just make it locally
> when I apply this patch to master.

...now applied to master, thanks.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]