Skip to content

Not possible to nest multiple progressbars #4

@StHagel

Description

@StHagel

Hey,
I tried nesting multiple progressbars like in this example:

#include <iostream>
#include "progressbar.hpp"

int main()
{
    ProgressBar pb1(100, 70);
    for (int i = 0; i < 100; ++i) {
        pb1.display();
        ++pb1;
        // Do additional stuff
        ProgressBar pb2(100, 70);
        for (int j = 0; j < 100; ++j) {
            pb2.display();
            ++pb2;
            // Do additional stuff
        }
        pb2.done();
    }
    pb1.done();
    return 0;
}

Unfortunately, this does not work. Instead the first progressbar disappears as soon as the second one gets displayed for the first time. After the second bar is finished, the first bar appears only for a brief moment, updates once, and disappears again.
Is there a way to nest two progressbars using the current implementation?
PS: If you want to run the example code, I recommend putting some sleep()/uslepp() in there, otherwise it will run too fast to notice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions