|
@@ -86,19 +86,23 @@ int imgexec ( struct image *image ) {
|
86
|
86
|
}
|
87
|
87
|
|
88
|
88
|
/**
|
89
|
|
- * Identify the first loaded image
|
|
89
|
+ * Identify the only loaded image
|
90
|
90
|
*
|
91
|
|
- * @ret image Image, or NULL
|
|
91
|
+ * @ret image Image, or NULL if 0 or >1 images are loaded
|
92
|
92
|
*/
|
93
|
93
|
struct image * imgautoselect ( void ) {
|
94
|
94
|
struct image *image;
|
|
95
|
+ struct image *selected_image = NULL;
|
|
96
|
+ int flagged_images = 0;
|
95
|
97
|
|
96
|
98
|
for_each_image ( image ) {
|
97
|
|
- if ( image->flags & IMAGE_LOADED )
|
98
|
|
- return image;
|
|
99
|
+ if ( image->flags & IMAGE_LOADED ) {
|
|
100
|
+ selected_image = image;
|
|
101
|
+ flagged_images++;
|
|
102
|
+ }
|
99
|
103
|
}
|
100
|
104
|
|
101
|
|
- return NULL;
|
|
105
|
+ return ( ( flagged_images == 1 ) ? selected_image : NULL );
|
102
|
106
|
}
|
103
|
107
|
|
104
|
108
|
/**
|