summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-11-17 06:47:24 +0000
committerDavid Robillard <d@drobilla.net>2014-11-17 06:47:24 +0000
commitb9e61de6668c6450d7b28040519ec2cb3b1ad87f (patch)
tree8f713df92343d28ae3676c8dba9431677069334f /src
parent8d34a6da879f0f8c39dfd4adfa616301fb655f18 (diff)
downloadingen-b9e61de6668c6450d7b28040519ec2cb3b1ad87f.tar.gz
ingen-b9e61de6668c6450d7b28040519ec2cb3b1ad87f.tar.bz2
ingen-b9e61de6668c6450d7b28040519ec2cb3b1ad87f.zip
Fix a few minor/unlikely memory errors.
Handle Glade widget loading failure more gracefully. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5486 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/LV2Features.cpp2
-rw-r--r--src/gui/NodeModule.cpp5
-rw-r--r--src/gui/Port.cpp5
-rw-r--r--src/gui/WindowFactory.cpp12
-rw-r--r--src/server/ControlBindings.cpp1
-rw-r--r--src/server/Engine.cpp8
-rw-r--r--src/server/ingen_lv2.cpp23
7 files changed, 41 insertions, 15 deletions
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp
index b3600f02..b6765ae3 100644
--- a/src/LV2Features.cpp
+++ b/src/LV2Features.cpp
@@ -35,7 +35,7 @@ LV2Features::add_feature(SPtr<Feature> feature)
LV2Features::FeatureArray::FeatureArray(FeatureVector& features)
: _features(features)
{
- _array = (LV2_Feature**)malloc(sizeof(LV2_Feature) * (features.size() + 1));
+ _array = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * (features.size() + 1));
_array[features.size()] = NULL;
for (size_t i = 0; i < features.size(); ++i) {
_array[i] = features[i].get();
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 0bacb70b..722cfa83 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -93,6 +93,11 @@ bool
NodeModule::show_menu(GdkEventButton* ev)
{
WidgetFactory::get_widget_derived("object_menu", _menu);
+ if (!_menu) {
+ app().log().error("Failed to load object menu widget\n");
+ return false;
+ }
+
_menu->init(app(), _block);
_menu->signal_embed_gui.connect(
sigc::mem_fun(this, &NodeModule::on_embed_gui_toggled));
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index e123a571..20f9cf90 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -141,6 +141,11 @@ Port::show_menu(GdkEventButton* ev)
{
PortMenu* menu = NULL;
WidgetFactory::get_widget_derived("object_menu", menu);
+ if (!menu) {
+ _app.log().error("Failed to load port menu widget\n");
+ return false;
+ }
+
menu->init(_app, model(), _flipped);
menu->popup(ev->button, ev->time);
return true;
diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp
index f6d07262..ebd008e6 100644
--- a/src/gui/WindowFactory.cpp
+++ b/src/gui/WindowFactory.cpp
@@ -14,8 +14,10 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdexcept>
#include <string>
+#include "ingen/Log.hpp"
#include "ingen/client/GraphModel.hpp"
#include "App.hpp"
@@ -51,6 +53,11 @@ WindowFactory::WindowFactory(App& app)
WidgetFactory::get_widget_derived("properties_win", _properties_win);
WidgetFactory::get_widget_derived("rename_win", _rename_win);
+ if (!(_load_plugin_win && _load_graph_win && _new_subgraph_win
+ && _properties_win && _rename_win)) {
+ throw std::runtime_error("failed to load window widgets\n");
+ }
+
_load_plugin_win->init_window(app);
_load_graph_win->init(app);
_new_subgraph_win->init_window(app);
@@ -157,6 +164,11 @@ WindowFactory::new_graph_window(SPtr<const GraphModel> graph,
GraphWindow* win = NULL;
WidgetFactory::get_widget_derived("graph_win", win);
+ if (!win) {
+ _app.log().error("Failed to load graph window widget\n");
+ return NULL;
+ }
+
win->init_window(_app);
win->box()->set_graph(graph, view);
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 6ffb5c7d..973874ae 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -339,6 +339,7 @@ ControlBindings::bind(ProcessContext& context, Key key)
_bindings->insert(make_pair(key, _learn_port));
uint8_t buf[128];
+ memset(buf, 0, sizeof(buf));
lv2_atom_forge_set_buffer(&_forge, buf, sizeof(buf));
forge_binding(uris, &_forge, key.type, key.num);
const LV2_Atom* atom = (const LV2_Atom*)buf;
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 71573ecb..76755a2c 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -339,11 +339,11 @@ Engine::run(uint32_t sample_count)
// Run root graph
if (_root_graph) {
_root_graph->process(_process_context);
- }
- // Emit control binding feedback
- control_bindings()->post_process(
- _process_context, _root_graph->port_impl(1)->buffer(0).get());
+ // Emit control binding feedback
+ control_bindings()->post_process(
+ _process_context, _root_graph->port_impl(1)->buffer(0).get());
+ }
return n_processed_events;
}
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index e73cc4ee..70642298 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -28,6 +28,7 @@
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h"
#include "lv2/lv2plug.in/ns/ext/log/log.h"
+#include "lv2/lv2plug.in/ns/ext/log/logger.h"
#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
@@ -501,6 +502,17 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
}
}
+ LV2_Log_Logger logger;
+ lv2_log_logger_init(&logger, map, log);
+
+ if (!map) {
+ lv2_log_error(&logger, "host did not provide URI map feature\n");
+ return NULL;
+ } else if (!unmap) {
+ lv2_log_error(&logger, "host did not provide URI unmap feature\n");
+ return NULL;
+ }
+
if (!Glib::thread_supported()) {
Glib::thread_init();
}
@@ -518,16 +530,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
}
if (!graph) {
- const std::string msg((fmt("Could not find graph %1%\n")
- % descriptor->URI).str());
- if (log) {
- log->printf(log->handle,
- map->map(map->handle, LV2_LOG__Error),
- msg.c_str(),
- NULL);
- } else {
- std::cerr << msg.c_str() << std::endl;
- }
+ lv2_log_error(&logger, "could not find graph <%s>\n", descriptor->URI);
return NULL;
}