Skip to content

Commit

Permalink
Fix some other crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Sep 1, 2015
1 parent b403524 commit a8bbb67
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 26 deletions.
12 changes: 7 additions & 5 deletions base/lib/core/application/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <core/document/DocumentBackups.hpp>
using namespace iscore;
#include <QMessageBox>
#include <QFileInfo>
#include "SafeQApplication.hpp"
static Application* application_instance = nullptr;

Expand All @@ -22,22 +23,23 @@ static void myMessageOutput(
const QMessageLogContext &context,
const QString &msg)
{
auto basename = QFileInfo(context.file).baseName().toLatin1().constData();
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), basename, context.line, context.function);
break;
case QtInfoMsg:
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), basename, context.line, context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), basename, context.line, context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), basename, context.line, context.function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), basename, context.line, context.function);
ISCORE_BREAKPOINT;
std::terminate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,14 @@ void IScoreCohesionControl::snapshotParametersInStates()

MessageList messages;
for(auto& index : indexes)
messages.push_back(DeviceExplorer::messageFromModelIndex(index));
{
auto m = DeviceExplorer::messageFromModelIndex(index);
if(m != iscore::Message{})
messages.push_back(m);
}

if(messages.empty())
return;

MacroCommandDispatcher macro{new CreateStatesFromParametersInEvents,
currentDocument()->commandStack()};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,26 @@ DeviceDocumentPlugin& DeviceExplorerModel::deviceModel() const

QModelIndexList DeviceExplorerModel::selectedIndexes() const
{
return m_view->selectedIndexes();
if(!m_view)
{
return {};
}
else
{
// We have to do this check if we have a proxy
if (m_view->hasProxy())
{
auto indexes = m_view->selectedIndexes();
for(auto& index : indexes)
index = static_cast<const QAbstractProxyModel *>(m_view->QTreeView::model())->mapToSource(index);
return indexes;
}
else
{
return m_view->selectedIndexes();
}

}
}

void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ iscore::Address DeviceExplorer::addressFromNode(const iscore::Node& m)

iscore::Message DeviceExplorer::messageFromNode(const iscore::Node& node)
{
if(!node.is<iscore::AddressSettings>())
return {};

iscore::Message mess;
mess.address = addressFromNode(node);

ISCORE_ASSERT(!node.is<iscore::DeviceSettings>());

mess.value = node.get<iscore::AddressSettings>().value;

return mess;
Expand Down
33 changes: 17 additions & 16 deletions base/plugins/iscore-plugin-ossia/iscore2OSSIA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,8 @@ OSSIA::Value* createOSSIAValue(const T& val)
return new typename boost::mpl::at<OSSIATypeMap, T>::type(val);
}


OSSIA::Value* toValue(
const iscore::Value& value)
static OSSIA::Value* toValue(const QVariant& val)
{
const QVariant& val = value.val;
switch(static_cast<QMetaType::Type>(val.type()))
{
case QMetaType::Type::UnknownType: // == QVariant::Invalid
Expand All @@ -243,24 +240,22 @@ OSSIA::Value* toValue(
return createOSSIAValue(val.value<char>());
case QMetaType::Type::QString:
return createOSSIAValue(val.value<QString>().toStdString());
//TODO tuple & generic

/*
case OSSIA::Value::Type::Tuple:
case QMetaType::Type::QVariantList:
{
ISCORE_TODO;
QVariantList tuple = data.value<QVariantList>();
const auto& vec = dynamic_cast<OSSIA::Tuple&>(val).value;
ISCORE_ASSERT(tuple.size() == (int)vec.size());
for(int i = 0; i < (int)vec.size(); i++)
QVariantList tuple = val.value<QVariantList>();
auto ossia_tuple = new OSSIA::Tuple;
for(const auto& val : tuple)
{
updateOSSIAValue(tuple[i], *vec[i]);
ossia_tuple->value.push_back(toValue(val));
}
return ossia_tuple;
break;
}
case OSSIA::Value::Type::GENERIC:
case QMetaType::Type::QByteArray:
{
//return createOSSIAValue(val.value<QByteArray>());
ISCORE_TODO;
/*
const auto& array = data.value<QByteArray>();
auto& generic = dynamic_cast<OSSIA::Generic&>(val);
Expand All @@ -270,9 +265,9 @@ OSSIA::Value* toValue(
generic.start = new char[generic.size];
boost::range::copy(array, generic.start);
*/
break;
}
*/
default:
break;
}
Expand All @@ -283,6 +278,12 @@ OSSIA::Value* toValue(
return nullptr;
}

OSSIA::Value* toValue(
const iscore::Value& value)
{
return toValue(value.val);
}

std::shared_ptr<OSSIA::Message> message(const iscore::Message& mess, const DeviceList& deviceList)
{
if(!deviceList.hasDevice(mess.address.device))
Expand Down

0 comments on commit a8bbb67

Please sign in to comment.