改变Goocanvas中的椭圆颜色

时间:2015-09-03 20:30:53

标签: c++ gtkmm

我试图更改状态的颜色(由椭圆表示)以说明它何时处于活动状态,但我收到此错误:

分段错误(核心转储)

代码是:

    int AutomataGui::setNodeAsActive(std::string nodeName){
    GuiNode* node = this->getNodeByName(nodeName);
    if (node == NULL)
        return -1;
    this->drawAsActiveNode(node);
    return 0;
 }

    GuiNode* AutomataGui::getNodeByName(std::string name){
        std::list<GuiNode> nodeList = *(this->currentGuiSubautomata->getListGuiNodes());

        std::list<GuiNode>::iterator nodeListIter = nodeList.begin();
        while (nodeListIter != nodeList.end()){
            if (nodeListIter->getName().compare(name) == 0){
                return &(*nodeListIter);
            }
            nodeListIter++;
        }
    return NULL;
}

    void AutomataGui::drawAsActiveNode(GuiNode* gnode){
    if (this->currentActiveNode){
        this->currentActiveNode->changeColor(ITEM_COLOR_BLUE);
    }
    gnode->changeColor(ITEM_COLOR_GREEN);
    this->currentActiveNode = gnode;
 }

    void GuiNode::changeColor ( std::string newColor ){
    #ifdef GLIBMM_PROPERTIES_ENABLED
    this->ellipse->property_fill_color() = newColor;
    #else
    this->ellipse->set_property("fill_color", Glib::ustring(newColor));
    #endif //GLIBMM_PROPERTIES_ENABLED
}

问题是this->currentActiveNode NULL它可以正常工作,但是当它不是时就会给我错误。

0 个答案:

没有答案