@@ -566,7 +566,8 @@ vips_php_zval_to_gval(VipsImage *match_image, zval *zvalue, GValue *gvalue)
566
566
}
567
567
568
568
static int
569
- vips_php_set_value (VipsPhpCall * call , GParamSpec * pspec , zval * zvalue )
569
+ vips_php_set_value (VipsPhpCall * call ,
570
+ GParamSpec * pspec , VipsArgumentFlags flags , zval * zvalue )
570
571
{
571
572
const char * name = g_param_spec_get_name (pspec );
572
573
GType pspec_type = G_PARAM_SPEC_VALUE_TYPE (pspec );
@@ -581,7 +582,8 @@ vips_php_set_value(VipsPhpCall *call, GParamSpec *pspec, zval *zvalue)
581
582
/* If we are setting a MODIFY VipsArgument with an image, we need to take a
582
583
* copy.
583
584
*/
584
- if (g_type_is_a (pspec_type , VIPS_TYPE_IMAGE )) {
585
+ if (g_type_is_a (pspec_type , VIPS_TYPE_IMAGE ) &&
586
+ (flags & VIPS_ARGUMENT_MODIFY )) {
585
587
VipsImage * image ;
586
588
VipsImage * memory ;
587
589
@@ -647,7 +649,7 @@ vips_php_set_required_input(VipsObject *object,
647
649
}
648
650
649
651
if (arg &&
650
- vips_php_set_value (call , pspec , arg )) {
652
+ vips_php_set_value (call , pspec , argument_class -> flags , arg )) {
651
653
return call ;
652
654
}
653
655
}
@@ -686,7 +688,7 @@ vips_php_set_optional_input(VipsPhpCall *call, zval *options)
686
688
if (!(argument_class -> flags & VIPS_ARGUMENT_REQUIRED ) &&
687
689
(argument_class -> flags & VIPS_ARGUMENT_INPUT ) &&
688
690
!(argument_class -> flags & VIPS_ARGUMENT_DEPRECATED ) &&
689
- vips_php_set_value (call , pspec , value )) {
691
+ vips_php_set_value (call , pspec , argument_class -> flags , value )) {
690
692
return -1 ;
691
693
}
692
694
} ZEND_HASH_FOREACH_END ();
@@ -891,6 +893,12 @@ vips_php_get_optional_output(VipsPhpCall *call, zval *options,
891
893
continue ;
892
894
}
893
895
896
+ /* value should always be TRUE.
897
+ */
898
+ if (Z_TYPE_P (value ) != IS_TRUE ) {
899
+ continue ;
900
+ }
901
+
894
902
name = ZSTR_VAL (key );
895
903
if (vips_object_get_argument (VIPS_OBJECT (call -> operation ), name ,
896
904
& pspec , & argument_class , & argument_instance )) {
@@ -1046,7 +1054,6 @@ PHP_FUNCTION(vips_call)
1046
1054
char * operation_name ;
1047
1055
size_t operation_name_len ;
1048
1056
zval * instance ;
1049
- int i ;
1050
1057
1051
1058
VIPS_DEBUG_MSG ("vips_call:\n" );
1052
1059
@@ -1182,7 +1189,7 @@ PHP_FUNCTION(vips_image_new_from_array)
1182
1189
int width ;
1183
1190
int height ;
1184
1191
VipsImage * mat ;
1185
- int x , y ;
1192
+ int x ;
1186
1193
zval * row ;
1187
1194
1188
1195
VIPS_DEBUG_MSG ("vips_image_new_from_array:\n" );
@@ -1237,6 +1244,8 @@ PHP_FUNCTION(vips_image_write_to_file)
1237
1244
zval * options = NULL ;
1238
1245
VipsImage * image ;
1239
1246
1247
+ VIPS_DEBUG_MSG ("vips_image_write_to_file:\n" );
1248
+
1240
1249
if (zend_parse_parameters (ZEND_NUM_ARGS (), "rp|a" ,
1241
1250
& IM , & filename , & filename_len , & options ) == FAILURE ) {
1242
1251
RETURN_LONG (-1 );
@@ -1247,6 +1256,8 @@ PHP_FUNCTION(vips_image_write_to_file)
1247
1256
RETURN_LONG (-1 );
1248
1257
}
1249
1258
1259
+ VIPS_DEBUG_MSG ("\t%p -> %s\n" , image , filename );
1260
+
1250
1261
if (vips_image_write_to_file (image , filename , NULL )) {
1251
1262
RETURN_LONG (-1 );
1252
1263
}
@@ -1477,7 +1488,6 @@ PHP_FUNCTION(vips_image_remove)
1477
1488
char * field_name ;
1478
1489
size_t field_name_len ;
1479
1490
VipsImage * image ;
1480
- GType type ;
1481
1491
1482
1492
if (zend_parse_parameters (ZEND_NUM_ARGS (), "rs" ,
1483
1493
& im , & field_name , & field_name_len ) == FAILURE ) {
@@ -1606,6 +1616,12 @@ PHP_MINIT_FUNCTION(vips)
1606
1616
le_gobject = zend_register_list_destructors_ex (php_free_gobject ,
1607
1617
NULL , "GObject" , module_number );
1608
1618
1619
+ #ifdef VIPS_DEBUG
1620
+ printf ( "php-vips-ext init\n" );
1621
+ printf ( "enabling vips leak testing ...\n" );
1622
+ vips_leak_set ( TRUE );
1623
+ #endif /*VIPS_DEBUG*/
1624
+
1609
1625
return SUCCESS ;
1610
1626
}
1611
1627
/* }}} */
@@ -1618,6 +1634,10 @@ PHP_MSHUTDOWN_FUNCTION(vips)
1618
1634
UNREGISTER_INI_ENTRIES();
1619
1635
*/
1620
1636
1637
+ #ifdef VIPS_DEBUG
1638
+ printf ( "php-vips-ext shutdown\n" );
1639
+ #endif /*VIPS_DEBUG*/
1640
+
1621
1641
vips_shutdown ();
1622
1642
1623
1643
return SUCCESS ;
0 commit comments