Commit 34f6ef31 authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED bug: do not record null viewer is the component viewer's list

When testcomponents is ran, no viewer extensions are loaded.
Application::getViewer(..) returns nullptr. As MeshComponent set its
visibility in the 3DViewer, and there is no 3DViewer, nullptr was registered
in the list. This caused a crash later on, when refresh() was called.
parent 2c27db64
......@@ -190,7 +190,7 @@ void ReorientImage::initInternalViewer() {
buildGeometries();
// Set up the 3D viewer to visualize actual origin/orientation locations
internalViewer = dynamic_cast<InteractiveGeometryViewer*>(Application::getNewViewer("Image Orientation Viewer", "InteractiveGeometryViewer"));
internalViewer = dynamic_cast<InteractiveGeometryViewer*>(Application::getNewViewer("Image Orientation Viewer", "InteractiveGeometryViewer"));
internalViewer->setLayout(Viewer::EMBEDDED);
internalViewer->setHighlightMode(InteractiveViewer::OFF);
internalViewer->toggleCopyright(false);
......
......@@ -43,7 +43,7 @@ QString VRMLComponentExtension::getName() const {
// --------------- getDescription -------------------
QString VRMLComponentExtension::getDescription() const {
return tr("Manage VRML 2 <em>.wrl .vrml</em> files in <b>CamiTK</b>.(very few support!)");
return tr("Basic support for VRML 2 <em>.wrl</em> and <em>.vrml</em> documents");
}
// --------------- getFileExtensions -------------------
......
......@@ -259,14 +259,17 @@ Component* Component::getTopLevelComponent() {
// -------------------- setVisibility --------------------
void Component::setVisibility(Viewer* v, bool b) {
QMap<Viewer*, bool>::iterator it = myViewers.find(v);
// only insert real non-null viewers
if (v != nullptr) {
QMap<Viewer*, bool>::iterator it = myViewers.find(v);
if (it == myViewers.end()) {
// insert the new viewer with the corresponding boolean
myViewers.insert(v, b);
}
else {
it.value() = b;
if (it == myViewers.end()) {
// insert the new viewer with the corresponding boolean
myViewers.insert(v, b);
}
else {
it.value() = b;
}
}
}
......
......@@ -216,7 +216,10 @@ private:
static InterfaceLogger* applicationLogger;
};
// Generic log macro (it is NOT recommended to use it directly...)
/// Helper macro that produce a QString reprensenting a pointer
#define CAMITK_PRINT_POINTER(PTR) (QString(#PTR) + QString("=0x%1").arg((quintptr)PTR, QT_POINTER_SIZE * 2, 16, QChar('0')))
/// Generic log macro (it is NOT recommended to use it directly...)
#if !defined(CAMITK_DISABLE_LOG)
#define CAMITK_LOG(LEVEL,MSG,SENDER) camitk::Log::getLogger()->log(MSG, LEVEL, __FILE__, Q_FUNC_INFO, __LINE__, SENDER);
#define CAMITK_LOG_ALT(LEVEL,MSG) camitk::Log::getLogger()->log(MSG, LEVEL, __FILE__, __func__, __LINE__);
......
......@@ -37,6 +37,6 @@ ExplorerExtension::ExplorerExtension() : ViewerExtension() {
// --------------- getViewers -------------------
void ExplorerExtension::init() {
registerDefaultViewer(Explorer);
registerDefaultViewer(Explorer);
}
......@@ -33,29 +33,29 @@
#include <ViewerExtension.h>
class FRAMEEXPLORER_API FrameExplorerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.frameexplorerextension.viewer.frameexplorerextension")
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.frameexplorerextension.viewer.frameexplorerextension")
public:
/// Constructor
FrameExplorerExtension() : ViewerExtension() {};
/// Constructor
FrameExplorerExtension() : ViewerExtension() {};
/// Destructor
virtual ~FrameExplorerExtension() = default;
/// Destructor
virtual ~FrameExplorerExtension() = default;
/// Method returning the action extension name
virtual QString getName() {
return "Frame Explorer Extension";
};
/// Method returning the action extension name
virtual QString getName() {
return "Frame Explorer Extension";
};
/// Method returning the action extension descrption
virtual QString getDescription() {
return "An extension for the frame explorer";
};
/// Method returning the action extension descrption
virtual QString getDescription() {
return "An extension for the frame explorer";
};
/// initialize all the actions
virtual void init();
/// initialize all the actions
virtual void init();
};
......
......@@ -31,9 +31,9 @@
// --------------- getViewers -------------------
void InteractiveSliceViewerExtension::init() {
registerNewViewer(InteractiveSliceViewer, "axialViewer");
registerNewViewer(InteractiveSliceViewer, "coronalViewer");
registerNewViewer(InteractiveSliceViewer, "sagittalViewer");
registerNewViewer(InteractiveSliceViewer, "arbitraryViewer");
registerNewViewer(InteractiveSliceViewer, "axialViewer");
registerNewViewer(InteractiveSliceViewer, "coronalViewer");
registerNewViewer(InteractiveSliceViewer, "sagittalViewer");
registerNewViewer(InteractiveSliceViewer, "arbitraryViewer");
}
......@@ -140,7 +140,7 @@ QWidget* MedicalImageViewer::getWidget() {
Application::getViewer("sagittalViewer")->embedIn(innerLayout);
innerLayout = new QVBoxLayout();
frameLayout->addLayout(innerLayout, 0, 1); // north-east
Application::getViewer("3DViewer")->embedIn(innerLayout);
Application::getViewer("arbitraryViewer")->embedIn(innerLayout);
......
......@@ -33,29 +33,29 @@
#include <ViewerExtension.h>
class PROPERTYEXPLORER_API PropertyExplorerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.propertyexplorerextension.viewer.propertyexplorerextension")
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.propertyexplorerextension.viewer.propertyexplorerextension")
public:
/// Constructor
PropertyExplorerExtension() : ViewerExtension() {};
/// Constructor
PropertyExplorerExtension() : ViewerExtension() {};
/// Destructor
virtual ~PropertyExplorerExtension() = default;
/// Destructor
virtual ~PropertyExplorerExtension() = default;
/// Method returning the action extension name
virtual QString getName() {
return "Property Explorer Extension";
};
/// Method returning the action extension name
virtual QString getName() {
return "Property Explorer Extension";
};
/// Method returning the action extension descrption
virtual QString getDescription() {
return "An extension for the property explorer";
};
/// Method returning the action extension descrption
virtual QString getDescription() {
return "An extension for the property explorer";
};
/// initialize all the actions
virtual void init();
/// initialize all the actions
virtual void init();
};
......
......@@ -31,6 +31,6 @@
// --------------- getActions -------------------
void TextViewerExtension::init() {
registerDefaultViewer(TextViewer);
registerDefaultViewer(TextViewer);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment