diff -u glom-1.6.0/debian/changelog glom-1.6.0/debian/changelog --- glom-1.6.0/debian/changelog +++ glom-1.6.0/debian/changelog @@ -1,3 +1,10 @@ +glom (1.6.0-0ubuntu3) gutsy-proposed; urgency=low + + * New patch, 60_allow-changing-field-types, fixes bug preventing any other + field type than numeric; LP: #186869. + + -- Loic Minier Wed, 16 Apr 2008 14:42:22 +0200 + glom (1.6.0-0ubuntu2) gutsy; urgency=low * Rebuild against new libgdamm. only in patch2: unchanged: --- glom-1.6.0.orig/debian/patches/60_allow-changing-field-types.patch +++ glom-1.6.0/debian/patches/60_allow-changing-field-types.patch @@ -0,0 +1,140 @@ +Ubuntu #186869 + +2007-10-17 Murray Cumming + + * glom/libglom/data_structure/field.cc: + * glom/libglom/data_structure/field.h: Copy constructor: + copy m_field_info instead of sharing one reference-counted instance. + get_field_info(): Add a const overload and make the existing one non-const. + This const correctness should prevent us from using the same instance when + we actually want to explicitly take a copy. + This errors were probably caused during the port to libgda 3.0, when + Gda::Column became a reference-counted object. + * glom/mode_design/fields/box_db_table_definition.cc: + get_field_definition(): copy the field_info instead of just reusing the + existing one, to avoid changing the original field_info accidentally. + + These changes make field type changes actually work again in 1.6. + +Index: glom/libglom/data_structure/field.cc +=================================================================== +--- glom/libglom/data_structure/field.cc (revision 1216) ++++ glom/libglom/data_structure/field.cc (revision 1217) +@@ -60,7 +60,7 @@ Field& Field::operator=(const Field& src + TranslatableItem::operator=(src); + + m_glom_type = src.m_glom_type; +- m_field_info = src.m_field_info; ++ m_field_info = src.m_field_info->copy(); + m_data = src.m_data; + + m_lookup_relationship = src.m_lookup_relationship; +@@ -78,7 +78,7 @@ Field& Field::operator=(const Field& src + bool Field::operator==(const Field& src) const + { + return TranslatableItem::operator==(src) +- && (m_field_info == src.m_field_info) ++ && (m_field_info->equal(src.m_field_info)) + && (m_glom_type == src.m_glom_type) + && (m_data == src.m_data) + && (m_lookup_relationship == src.m_lookup_relationship) +@@ -108,7 +108,12 @@ void Field::set_glom_type(glom_field_typ + m_glom_type = fieldtype; + } + +-Glib::RefPtr Field::get_field_info() const ++Glib::RefPtr Field::get_field_info() ++{ ++ return m_field_info; ++} ++ ++Glib::RefPtr Field::get_field_info() const + { + return m_field_info; + } +@@ -524,6 +529,8 @@ GType Field::get_gda_type_for_glom_type( + { + g_warning("Field::get_gda_type_for_glom_type(): Returning G_TYPE_NONE for glom_type=%d", glom_type); + } ++ ++ //std::cout << "Field::get_gda_type_for_glom_type(): returning: " << g_type_name(ideal_gda_type) << std::endl; + + return ideal_gda_type; + } +Index: glom/libglom/data_structure/field.h +=================================================================== +--- glom/libglom/data_structure/field.h (revision 1216) ++++ glom/libglom/data_structure/field.h (revision 1217) +@@ -126,7 +126,8 @@ public: + + + //TODO_Performance: Lots of code calls this just to call one of its methods: +- Glib::RefPtr get_field_info() const; ++ Glib::RefPtr get_field_info(); ++ Glib::RefPtr get_field_info() const; + void set_field_info(const Glib::RefPtr& fieldInfo); + + /// Ignores any part of FieldAttributes that libgda does not properly fill. +Index: glom/mode_design/fields/box_db_table_definition.cc +=================================================================== +--- glom/mode_design/fields/box_db_table_definition.cc (revision 1216) ++++ glom/mode_design/fields/box_db_table_definition.cc (revision 1217) +@@ -370,7 +370,7 @@ sharedptr Box_DB_Table_Definition + sharedptr field_temp = get_fields_for_table_one_field(m_table_name, strFieldNameBeforeEdit); + if(field_temp) + { +- Glib::RefPtr fieldInfo = field_temp->get_field_info(); ++ Glib::RefPtr fieldInfo = field_temp->get_field_info()->copy(); + + //Name: + const Glib::ustring name = m_AddDel.get_value(row, m_colName); +@@ -563,8 +563,8 @@ void Box_DB_Table_Definition::fill_field + + sharedptr Box_DB_Table_Definition::postgres_change_column(const sharedptr& field_old, const sharedptr& field) + { +- const Glib::RefPtr field_info = field->get_field_info(); +- const Glib::RefPtr field_info_old = field_old->get_field_info(); ++ const Glib::RefPtr field_info = field->get_field_info(); ++ const Glib::RefPtr field_info_old = field_old->get_field_info(); + + //If the underlying data type has changed: + if(field_info->get_g_type() != field_info_old->get_g_type() ) +@@ -708,16 +708,31 @@ void Box_DB_Table_Definition::postgres_c + Glib::RefPtr datamodel = query_execute( "ALTER TABLE \"" + m_table_name + "\" DROP COLUMN \"" + field_old->get_name() + "\"", get_app_window()); + if(datamodel) + { +- datamodel = query_execute( "ALTER TABLE \"" + m_table_name + "\" RENAME COLUMN \"" + fieldTemp->get_name() + "\" TO \"" + field->get_name() + "\"", get_app_window()); +- if(datamodel) ++ const Glib::ustring sql = "ALTER TABLE \"" + m_table_name + "\" RENAME COLUMN \"" + fieldTemp->get_name() + "\" TO \"" + field->get_name() + "\""; ++ try + { +- const bool test = gda_connection->commit_transaction(transaction_name); +- if(!test) ++ datamodel = query_execute(sql, get_app_window()); ++ if(datamodel) + { +- handle_error(); ++ const bool test = gda_connection->commit_transaction(transaction_name); ++ if(!test) ++ { ++ std::cerr << "Box_DB_Table_Definition::postgres_change_column_type(): Error while executing SQL:" << std::endl << " " << sql << std::endl; ++ handle_error(); ++ } ++ else ++ new_column_created = true; + } +- else +- new_column_created = true; ++ } ++ catch(const Glib::Error& ex) ++ { ++ std::cerr << "Box_DB_Table_Definition::postgres_change_column_type(): Glib::Error exception while executing SQL:" << std::endl << " " << sql << std::endl; ++ handle_error(ex); ++ } ++ catch(const std::exception& ex) ++ { ++ std::cerr << "Box_DB_Table_Definition::postgres_change_column_type(): std::exception while executing SQL:" << std::endl << " " << sql << std::endl; ++ handle_error(ex); + } + } + }