DICOMEventHandler Crashes when loading DICOM data with special character in the file path
Open, HighPublic

Description

The MITK DICOM Browser crashes if you try to load a dicom file, that has a file path containing special characters.

Reason is that DicomEventHandler::OnSignalAddSeriesToDataManager uses QString::toStdString() to convert into an std::string. That may corrupt special characters and lead to GDCM failing when testing if it can read the file.

Potential solutions (after some web research):

  • QString's toLocal8Bit().constData() (due to windows)
  • std::codecvt and std::wstring_convert
WARNING: Check OnSignalAddSeriesToDataManager() for several instances of the error. It should be at least for normal DICOM images and RT Dose.
floca created this task.Sep 4 2017, 1:49 PM
steint claimed this task.Mon, Apr 9, 2:20 PM
steint added a comment.EditedMon, Apr 9, 3:09 PM

I am planing on a platform independent approach for Windows and Mac
Source: https://stackoverflow.com/questions/26740785/preserve-non-ascii-characters-between-stdstring-and-qstring

steint added a comment.EditedMon, Apr 9, 3:30 PM

Pushed new branch T23338-fix-dicom-loading-special-character.

I have successfully tested mitk-data/RT and mitk-data/DICOMReader with special characters within path.

steint added a subscriber: kislinsk.Mon, Apr 9, 3:43 PM

@kislinsk I am not sure if there is a more generic special-character method which is platform indepenedent. I've read something about Boost (boost::filesystem::path) so maybe there is an alternative? Seems to me that this issue could be useful at other importer-like places too.

For now i would go with:

#ifdef Q_OS_WIN
	return string.toLocal8Bit().constData();
#elif Q_OS_MAC
	return string.toUtf8().constData();
#endif
floca added a comment.Mon, Apr 9, 5:04 PM

@kislinsk I am not sure if there is a more generic special-character method which is platform indepenedent. I've read something about Boost (boost::filesystem::path) so maybe there is an alternative? Seems to me that this issue could be useful at other importer-like places too.

FYI boost filesystem would introduce the need of boost binaries into the DICOM module. Would be great of we can keep it boost header only.