diff --git a/cplusplus/VImage.cc b/cplusplus/VImage.cc index a09971c9..8ef35d96 100644 --- a/cplusplus/VImage.cc +++ b/cplusplus/VImage.cc @@ -37,8 +37,9 @@ #include /* -#define DEBUG */ +#define VIPS_DEBUG +#define DEBUG VIPS_NAMESPACE_START @@ -62,6 +63,7 @@ VOption *VOption::set( const char *name, const char *value ) return( this ); } +// input int ... this path is used for enums as well VOption *VOption::set( const char *name, int value ) { Pair *pair = new Pair( name ); @@ -74,6 +76,7 @@ VOption *VOption::set( const char *name, int value ) return( this ); } +// input image VOption *VOption::set( const char *name, VImage value ) { Pair *pair = new Pair( name ); @@ -87,6 +90,7 @@ VOption *VOption::set( const char *name, VImage value ) return( this ); } +// output image VOption *VOption::set( const char *name, VImage *value ) { Pair *pair = new Pair( name ); @@ -108,12 +112,14 @@ void VOption::set_operation( VipsOperation *operation ) for( i = options.begin(); i != options.end(); i++ ) if( (*i)->input ) { +#ifdef DEBUG printf( "set_operation: " ); vips_object_print_name( VIPS_OBJECT( operation ) ); char *str_value = g_strdup_value_contents( &(*i)->value ); printf( ".%s = %s\n", (*i)->name, str_value ); g_free( str_value ); +#endif /*DEBUG*/ g_object_set_property( G_OBJECT( operation ), (*i)->name, &(*i)->value ); @@ -130,12 +136,14 @@ void VOption::get_operation( VipsOperation *operation ) g_object_get_property( G_OBJECT( operation ), (*i)->name, &(*i)->value ); +#ifdef DEBUG printf( "get_operation: " ); vips_object_print_name( VIPS_OBJECT( operation ) ); char *str_value = g_strdup_value_contents( &(*i)->value ); printf( ".%s = %s\n", (*i)->name, str_value ); g_free( str_value ); +#endif /*DEBUG*/ // rebox object VipsImage *image = VIPS_IMAGE( diff --git a/cplusplus/examples/invert.cc b/cplusplus/examples/invert.cc index 5eb27b00..2ccb984d 100644 --- a/cplusplus/examples/invert.cc +++ b/cplusplus/examples/invert.cc @@ -5,6 +5,8 @@ * */ +#define DEBUG + #include using namespace vips8; @@ -40,7 +42,9 @@ main( int argc, char **argv ) printf( "sizeof( VImage ) = %zd\n", sizeof( VImage ) ); { - VImage in = VImage::new_from_file( argv[1] ); + VImage in = VImage::new_from_file( argv[1], + VImage::option()->set( "access", VIPS_ACCESS_SEQUENTIAL_UNBUFFERED ) ); + VImage out; out = in.invert(); diff --git a/cplusplus/include/vips/VImage8.h b/cplusplus/include/vips/VImage8.h index b839acf8..fd94213e 100644 --- a/cplusplus/include/vips/VImage8.h +++ b/cplusplus/include/vips/VImage8.h @@ -60,6 +60,7 @@ public: g_assert( !new_vobject || VIPS_IS_OBJECT( new_vobject ) ); +#ifdef DEBUG printf( "VObject constructor, obj = %p, steal = %d\n", new_vobject, steal ); if( new_vobject ) { @@ -67,8 +68,12 @@ public: vips_object_print_name( VIPS_OBJECT( new_vobject ) ); printf( "\n" ); } +#endif /*DEBUG*/ + if( !steal ) { +#ifdef DEBUG printf( " reffing object\n" ); +#endif /*DEBUG*/ g_object_ref( vobject ); } } @@ -84,10 +89,12 @@ public: { g_assert( VIPS_IS_OBJECT( a.vobject ) ); +#ifdef DEBUG printf( "VObject copy constructor, obj = %p\n", vobject ); - g_object_ref( vobject ); printf( " reffing object\n" ); +#endif /*DEBUG*/ + g_object_ref( vobject ); } // assignment ... we must delete the old ref @@ -96,9 +103,11 @@ public: { VipsObject *old_vobject; +#ifdef DEBUG printf( "VObject assignment\n" ); printf( " reffing %p\n", a.vobject ); printf( " unreffing %p\n", vobject ); +#endif /*DEBUG*/ g_assert( !vobject || VIPS_IS_OBJECT( vobject ) ); @@ -120,8 +129,10 @@ public: // no vtable allowed ~VObject() { +#ifdef DEBUG printf( "VObject destructor\n" ); printf( " unreffing %p\n", vobject ); +#endif /*DEBUG*/ g_assert( !vobject || VIPS_IS_OBJECT( vobject ) );