
6 Sep
2008
6 Sep
'08
7:10 p.m.
TextTool::TextTool(QDialog *taskDialogue) : Tool(this->name) { boost::shared_ptr<TextTool> pointerToThis = TextTool::shared_from_this(); //ERROR OCCURS ON THIS LINE
bold = boost::shared_ptr<ToggleControl>(new ToggleControl(pointerToThis)); }
You cannot call shared_from_this in the constructor. Instead, you can define a static constructing method, like this: // untested!! static boost::shared_ptr<TextTool> TextTool::create(QDialog *taskDialogue) { boost::shared_ptr<TextTool> pointerToThis(new TextTool(taskDialogue)); pointerToThis->bold.reset(new ToggleControl(pointerToThis)); return pointerToThis; }