1

I am using wxwidgets and I have a code like this:

    gaugeProgressFolders->SetRange(folderList.size());
    for(int i=0;i<folderList.size();i++)
    {
        ProcessOneSet(folderList[i]);
        gaugeProgressFolders->SetValue(i+1);          
        wxYield();
    }

The wxYeild doesn't update guauge. I am wondering why it is not working?

Looking at wxYield, I noted that it returns a bool but there is no documentation on what it returns.

Why my guauge is not update and how I can fix it?

what wxYield returns?

ravenspoint
  • 19,093
  • 6
  • 57
  • 103
mans
  • 17,104
  • 45
  • 172
  • 321
  • I searched the spec I can't find what it returns either. – Neil Kirk Oct 27 '14 at 15:18
  • It's been years since I did anything wx, and few memories remain, but the mere mention of `wxYield` brings up shudders and nasty memories of weird reentrancy errors that are near impossible to diagnose from the callstack and that take forever to fix. Yuck. Sorry. – Damon Oct 27 '14 at 16:32

2 Answers2

1

You do not say what gaugeProgressFolders is. Perhaps it is wxGauge?

In any case, why do you expect wxYield to magically update the display?

You have to write code to update the display.

Assuming various things about your code, you could write something like this:

gaugeProgressFolders->SetRange(folderList.size());
for(int i=0;i<folderList.size();i++)
{
    ProcessOneSet(folderList[i]);
    gaugeProgressFolders->SetValue(i+1);          
    // wxYield();  Don't call this, it does nothing

    // force the window to be repainted RIGHT NOW.
    Refresh();
    Update();
}

You might also try the following, for the sake of efficency and less flicker

   // force the gauge to be repainted.
    gaugeProgressFolders->Refresh();
    gaugeProgressFolders->Update();
Lauri Nurmi
  • 566
  • 1
  • 3
  • 14
ravenspoint
  • 19,093
  • 6
  • 57
  • 103
0

Perhaps this is a little late to respond, but I don't think wxYield() is the right call for your purpose of updating a gauge. Perhaps try:

gaugeProgressFolders->SetRange(folderList.size());
    for (int i = 0; i < folderList.size(); i++)
    {
        ProcessOneSet(folderList[i]);
        gaugeProgressFolders->SetValue(i+1);          
        this->Layout(); //this being your window/dialog/frame
    }

Layout() forces the layout to redraw. It has been effective for me in the past.

blueberryredbull
  • 219
  • 1
  • 11