Hello,
I have created some custom classes, so called “ROIs” (regions-of-interest) inheriting from TQObject and draw objects, and experience some funny behavior. Attached you find a minimal example.
The inheritance chart is:
TQObject
|
ROI (abstract base class)
|
ROIEllipse – TEllipse (graphics object for ROIEllipse and ROICircle)
|
ROICircle
Now, from right-clicking the image in the GUI you can create ROIEllipse and ROICircle and save the to a ROOT file. For ROIEllipse I get the warning
but NOT for its child ROICircle!!! The warning is nonsense anyway, because there actually IS a default constructor!!!
If I delete the ROIs and load them from file again (right-click the image), I get the error
again not for child class ROICircle which loads fine.
I have implemented the copy constructor and operator= which is forced by TQObject and I don’t see why I would get the warnings/errors and why the child class ROICircle works while its parent ROIEllipse doesn’t.
Any ideas?
MyGui.zip (115 KB)
In file included from MyGui.cxx:13:0:
MyGui.h: In copy constructor ‘ROI::ROI(const ROI&)’:
MyGui.h:40:2: warning: base class ‘class TQObject’ should be explicitly initialized in the copy constructor [-Wextra]
ROI(const ROI &roi){}
^
MyGui.h: At global scope:
MyGui.h:40:2: warning: unused parameter ‘roi’ [-Wunused-parameter]
MyGui.cxx: In member function ‘virtual void MyMainFrame::LoadROIs()’:
MyGui.cxx:88:102: warning: format not a string literal and no format arguments [-Wformat-security]
Error("MyMainFrame::LoadROIs()", ("Cannot open file " + std::string(fi.fFilename) + " !!!").c_str());
^
MyGui.cxx: In member function ‘virtual void MyMainFrame::SaveROIs()’:
MyGui.cxx:123:82: warning: format not a string literal and no format arguments [-Wformat-security]
Error("MyMainFrame::SaveROIs()", "No write access to file " + filename + " !!!");
^
In file included from MyGuiDict.h:34:0,
from MyGuiDict.cxx:17:
MyGui.h: In copy constructor ‘ROI::ROI(const ROI&)’:
MyGui.h:40:2: warning: base class ‘class TQObject’ should be explicitly initialized in the copy constructor [-Wextra]
ROI(const ROI &roi){}
^
MyGui.h: At global scope:
MyGui.h:40:2: warning: unused parameter ‘roi’ [-Wunused-parameter]
BTW. The “compile” line should look like this: `root-config --cxx --cflags` -g -O2 -W -Wall -o ${ProjectName} ${ProjectName}.cxx ${ProjectName}Dict.cxx `root-config --glibs` -lASImage
P.S. I noticed that the ROIEllipse problem is visible in ROOT 5.34 but not in recent 6.0[24].
Thanks for the comments regarding the flags, I have never seen these warnings before…
Took a full day to migrate my framework to ROOT 6, but currently it looks like everything is working and even some other C++11 workarounds aren’t necessary anymore. So far worth it…