diff --git a/Modules/Segmentation/Controllers/mitkToolManagerProvider.cpp b/Modules/Segmentation/Controllers/mitkToolManagerProvider.cpp index 92770a491f..6496dabc76 100644 --- a/Modules/Segmentation/Controllers/mitkToolManagerProvider.cpp +++ b/Modules/Segmentation/Controllers/mitkToolManagerProvider.cpp @@ -1,67 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkToolManagerProvider.h" //micro service includes #include #include mitk::ToolManagerProvider::ToolManagerProvider(): m_ToolManager(mitk::ToolManager::New(NULL)) { } mitk::ToolManagerProvider::~ToolManagerProvider() { this->m_ToolManager = NULL; } mitk::ToolManager* mitk::ToolManagerProvider::GetToolManager() { - return this->m_ToolManager; + return this->m_ToolManager.GetPointer(); } mitk::ToolManagerProvider* mitk::ToolManagerProvider::GetInstance() { static ServiceReference serviceRef; static ModuleContext* context = mitk::GetModuleContext(); if (!serviceRef) { // This is either the first time GetInstance() was called, // or a SingletonOneService instance has not yet been registered. serviceRef = context->GetServiceReference(); } if (serviceRef) { // We have a valid service reference. It always points to the service // with the lowest id (usually the one which was registered first). // This still might return a null pointer, if all SingletonOneService // instances have been unregistered (during unloading of the library, // for example). return context->GetService(serviceRef); } else { // No SingletonOneService instance was registered yet. return 0; } } diff --git a/Modules/Segmentation/Testing/mitkToolManagerProviderTest.cpp b/Modules/Segmentation/Testing/mitkToolManagerProviderTest.cpp index 9b85d3aea5..666bfb1b09 100644 --- a/Modules/Segmentation/Testing/mitkToolManagerProviderTest.cpp +++ b/Modules/Segmentation/Testing/mitkToolManagerProviderTest.cpp @@ -1,49 +1,49 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTestingMacros.h" #include "mitkToolManagerProvider.h" #include "itkLightObject.h" #include #include "mitkModuleContext.h" #include "mitkServiceReference.h" #include "mitkGlobalInteraction.h" class mitkToolManagerProviderTestClass { public: static void RegisterService(){ mitk::GetModuleContext()->RegisterService(mitk::ToolManagerProvider::New().GetPointer()); } }; int mitkToolManagerProviderTest(int, char* []) { MITK_TEST_BEGIN("ToolManagerProvider") mitk::GlobalInteraction::GetInstance()->Initialize("global"); mitkToolManagerProviderTestClass::RegisterService(); mitk::ToolManagerProvider* service = mitk::ToolManagerProvider::GetInstance(); MITK_TEST_CONDITION(service!=NULL,"Service was succesfully called"); - MITK_TEST_CONDITION((service->GetToolManager()) == (service->GetToolManager()), "Service singleton"); + MITK_TEST_CONDITION((service->GetToolManager()) == (mitk::ToolManagerProvider::GetInstance()->GetToolManager()), "Service singleton"); MITK_TEST_END() }