From 7a16a2e28299db9e01695f4f4c3bd62f43da0ef2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Sun, 17 Nov 2013 11:07:18 +0100 Subject: [PATCH] Fixes for MSVC11 build. --- Anyanka.pro | 6 +++++- agreinterface.cpp | 6 +++--- agreinterface.h | 2 +- datafilesloader.cpp | 10 +++++----- datamanager.cpp | 2 +- main.cpp | 5 +++++ signal.h | 1 + windows_defines.h | 6 ++++++ 8 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 windows_defines.h diff --git a/Anyanka.pro b/Anyanka.pro index 779d7e0..d5ec378 100644 --- a/Anyanka.pro +++ b/Anyanka.pro @@ -16,6 +16,9 @@ unix { LIBS += -ldl QMAKE_CXXFLAGS += -std=c++11 -Wall } +win32 { + SOURCES += windows_defines.h +} INCLUDEPATH += libAGRE # Add project root directory to work around VC11 include path scheme @@ -67,7 +70,8 @@ HEADERS += \ integrator.h \ integrationtablemodel.h \ gui/aboutanyanka.h \ - globalinfo.h + globalinfo.h \ + windows_defines.h FORMS += \ gui/mainwindow.ui \ diff --git a/agreinterface.cpp b/agreinterface.cpp index b022a97..eeef549 100644 --- a/agreinterface.cpp +++ b/agreinterface.cpp @@ -109,12 +109,12 @@ AGREInterface::ReturnCode AGREInterface::initialize() /* Public methods */ -const std::vector* AGREInterface::debugAGREInfo() +const std::vector& AGREInterface::debugAGREInfo() { if (!m_inited) - return nullptr; + throw std::bad_exception("Reader not initialized"); - return &m_readerIFace->debug_info_list(); + return m_readerIFace->debug_info_list(); } AGREInterface::ReturnCode AGREInterface::readFile(const std::string& fileName, std::shared_ptr& minfo) diff --git a/agreinterface.h b/agreinterface.h index 75d899c..749ac52 100644 --- a/agreinterface.h +++ b/agreinterface.h @@ -42,7 +42,7 @@ public: E_CANNOT_READ_FILE }; - const std::vector* debugAGREInfo(); + const std::vector& debugAGREInfo(); AGRE_ReturnCode lastAGREError() { AGRE_ReturnCode r = m_lastAGREError; m_lastAGREError = AGRE_ReturnCode::SUCCESS; return r; } ReturnCode initialize(); static AGREInterface* instance(); diff --git a/datafilesloader.cpp b/datafilesloader.cpp index 61a9a88..a1645ae 100644 --- a/datafilesloader.cpp +++ b/datafilesloader.cpp @@ -50,12 +50,12 @@ DataFilesLoader::ReturnCode DataFilesLoader::loadSingleRun(const QDir& path, std } else { QString errDesc = errorToString(AGREInterface::instance()->lastAGREError()); Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, "Error reading file '" + s + "'" + errDesc); - const std::vector* const dbgMsgs = AGREInterface::instance()->debugAGREInfo(); - if (dbgMsgs == nullptr) - Logger::log(Logger::Level::CRITICAL, ME_SENDER_STR, "Null pointer to debug messages list. This should not happen!\n"); - else { - for (const std::string& s : *dbgMsgs) + try { + const std::vector& dbgMsgs = AGREInterface::instance()->debugAGREInfo(); + for (const std::string& s : dbgMsgs) Logger::log(Logger::Level::INFO, ME_SENDER_STR, QString("AGRE debug:") + QString(s.c_str())); + } catch (std::bad_exception& ) { + Logger::log(Logger::Level::CRITICAL, ME_SENDER_STR, "Null pointer to debug messages list. This should not happen!\n"); } QMessageBox::warning(nullptr, "Error reading file '" + s + "'", errDesc); return ReturnCode::E_READ_ERROR; diff --git a/datamanager.cpp b/datamanager.cpp index 20e330c..0482962 100644 --- a/datamanager.cpp +++ b/datamanager.cpp @@ -32,7 +32,7 @@ const char DataManager::UNIT_MICROAMPERES_TEXT[] = {static_cast(0xB5), 0x4 const char DataManager::UNIT_MILLIAU_TEXT[] = {0x6D, 0x41, 0x55, 0x00}; const char DataManager::UNIT_MILLIVOLTS_TEXT[] = {0x6D, 0x56, 0x00}; const char DataManager::UNIT_WATTS_TEXT[] = {0x57, 0x00}; -const QStringList DataManager::DATA_DIR_SUFFIX = { "*.D" }; +const QStringList DataManager::DATA_DIR_SUFFIX = QStringList() << "*.D"; DataManager::DataManager(QObject* parent) : QObject(parent), diff --git a/main.cpp b/main.cpp index bb4b0e3..bd8eea9 100644 --- a/main.cpp +++ b/main.cpp @@ -25,12 +25,17 @@ #include "logger.h" #include #include +#ifdef Q_OS_WIN +#include "windows_defines.h" +#endif int main(int argc, char *argv[]) { QApplication a(argc, argv); +#ifndef COMPILER_MSVC11 #warning Revisit the metatype shared_ptr registration +#endif qRegisterMetaType>(); Logger::initializeGlobal(); diff --git a/signal.h b/signal.h index dded6ce..3034a7e 100644 --- a/signal.h +++ b/signal.h @@ -23,6 +23,7 @@ #ifndef SIGNAL_H #define SIGNAL_H +#include #include #include diff --git a/windows_defines.h b/windows_defines.h new file mode 100644 index 0000000..bb6e1bb --- /dev/null +++ b/windows_defines.h @@ -0,0 +1,6 @@ +#ifndef WINDOWS_DEFINES_H +#define WINDOWS_DEFINES_H + +#define COMPILER_MSVC11 + +#endif // WINDOWS_DEFINES_H -- 2.43.5