Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

How can changing code that is not called break functionality?

$
0
0

@hamoid wrote:

Hi! One is for C++ experts:

This code is never called in my program. It would draw a few circles if it was.

std::vector<ofPolyline> loops;
ofFbo preview;

void LoopPreview::draw(u_long frm, const glm::vec2 & pos, const glm::vec2 & sz) {
    if(preview.isAllocated()) {
        ImDrawList * draw_list = ImGui::GetWindowDrawList();
        for(auto & loop : loops) {
            draw_list->AddCircleFilled(pos, 5, ImColor(255, 0, 255), 12);
        }
    }
}

The weird thing is, if I make a change to that unused code it breaks the whole GUI.

void LoopPreview::draw(u_long frm, const glm::vec2 & pos, const glm::vec2 & sz) {
    if(preview.isAllocated()) {
        ImDrawList * draw_list = ImGui::GetWindowDrawList();
        for(auto & loop : loops) {
            // access vertices in the "loop" polyline 
            draw_list->AddCircleFilled(pos 
                                       + loop[static_cast<int>(frm)], // THIS BREAKS THE GUI
                                       5, ImColor(255, 0, 255), 12);
        }
    }
}

How can a change to an unused method break the program?

I did put breakpoints and print to the console to make sure the code is never executed.

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles