View Issue Details

IDProjectCategoryView StatusLast Update
0005750ardourbugspublic2013-10-26 14:05
Reporternolaiz Assigned To 
PrioritynormalSeverityblockReproducibilityalways
Status newResolutionopen 
Summary0005750: compilation failure due boost::shared_ptr to bool implicit cast
DescriptionArdour fails to compile because the compiler (gcc 4.6.4 , boost 1.53) refuse to cast a boost::shared_ptr to a bool on libs/pbd/properties.h +445 and gtk2_ardour/editor_regions.cc +297

I attach a patch checking "boost::shared_ptr<>.use_count() > 0" for the bool values.
TagsNo tags attached.

Activities

2013-10-26 13:19

 

boost_shared_ptr_bool_cast.patch (866 bytes)   
diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc
index 72a0da2..5386528 100644
--- a/gtk2_ardour/editor_regions.cc
+++ b/gtk2_ardour/editor_regions.cc
@@ -294,7 +294,7 @@ EditorRegions::add_region (boost::shared_ptr<Region> region)
 	string str;
 	TreeModel::Row row;
 	Gdk::Color c;
-	bool missing_source = boost::dynamic_pointer_cast<SilentFileSource>(region->source());
+	bool missing_source = boost::dynamic_pointer_cast<SilentFileSource>(region->source()).use_count>0;
 
 	if (!_show_automatic_regions && region->automatic()) {
 		return;
diff --git a/libs/pbd/pbd/properties.h b/libs/pbd/pbd/properties.h
index e65929c..49915fb 100644
--- a/libs/pbd/pbd/properties.h
+++ b/libs/pbd/pbd/properties.h
@@ -442,7 +442,7 @@ public:
 	}
 
 	operator bool () const {
-		return _current;
+		return _current.use_count() > 0;
 	}
 
 protected:

nolaiz

2013-10-26 13:27

reporter   ~0015458

Last edited: 2013-10-26 14:06

The first patch was wrong. New patch attached with more casts converted. Using shared_ptr<>!=0 instead.

Now it finishes the compilation OK

2013-10-26 14:05

 

boost_shared_ptr_bool_cast_2.patch (2,616 bytes)   
diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc
index 72a0da2..7c2eb84 100644
--- a/gtk2_ardour/editor_regions.cc
+++ b/gtk2_ardour/editor_regions.cc
@@ -294,7 +294,7 @@ EditorRegions::add_region (boost::shared_ptr<Region> region)
 	string str;
 	TreeModel::Row row;
 	Gdk::Color c;
-	bool missing_source = boost::dynamic_pointer_cast<SilentFileSource>(region->source());
+	bool missing_source = boost::dynamic_pointer_cast<SilentFileSource>(region->source())!=0;
 
 	if (!_show_automatic_regions && region->automatic()) {
 		return;
diff --git a/gtk2_ardour/export_preset_selector.cc b/gtk2_ardour/export_preset_selector.cc
index 9f699bb..02793f1 100644
--- a/gtk2_ardour/export_preset_selector.cc
+++ b/gtk2_ardour/export_preset_selector.cc
@@ -123,9 +123,9 @@ ExportPresetSelector::update_selection ()
 		}
 	}
 
-	save_button.set_sensitive (current);
-	remove_button.set_sensitive (current);
-	new_button.set_sensitive (!current && !text.empty() && !preset_name_exists);
+	save_button.set_sensitive (current!=0);
+	remove_button.set_sensitive (current!=0);
+	new_button.set_sensitive ((current==0) && !text.empty() && !preset_name_exists);
 }
 
 void
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 35e9a5c..30107bc 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -707,7 +707,7 @@ PortMatrix::io_from_bundle (boost::shared_ptr<Bundle> b) const
 bool
 PortMatrix::can_add_channels (boost::shared_ptr<Bundle> b) const
 {
-	return io_from_bundle (b);
+	return io_from_bundle (b)!=0;
 }
 
 void
@@ -730,7 +730,7 @@ PortMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
 bool
 PortMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
 {
-	return io_from_bundle (b);
+	return io_from_bundle (b) != 0;
 }
 
 void
diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc
index 60f575f..0347741 100644
--- a/gtk2_ardour/session_option_editor.cc
+++ b/gtk2_ardour/session_option_editor.cc
@@ -354,7 +354,7 @@ SessionOptionEditor::parameter_changed (std::string const & p)
 bool
 SessionOptionEditor::set_use_monitor_section (bool yn)
 {
-	bool had_monitor_section = _session->monitor_out();
+	bool had_monitor_section = _session->monitor_out() !=0;
 
 	if (yn) {
 		_session->add_monitor_section ();
diff --git a/libs/pbd/pbd/properties.h b/libs/pbd/pbd/properties.h
index e65929c..3c48854 100644
--- a/libs/pbd/pbd/properties.h
+++ b/libs/pbd/pbd/properties.h
@@ -442,7 +442,7 @@ public:
 	}
 
 	operator bool () const {
-		return _current;
+		return _current != 0;
 	}
 
 protected:

Issue History

Date Modified Username Field Change
2013-10-26 13:19 nolaiz New Issue
2013-10-26 13:19 nolaiz File Added: boost_shared_ptr_bool_cast.patch
2013-10-26 13:27 nolaiz Note Added: 0015458
2013-10-26 14:05 nolaiz File Added: boost_shared_ptr_bool_cast_2.patch
2013-10-26 14:06 nolaiz Note Edited: 0015458