@@ -1170,7 +1170,8 @@ static void _view_map_draw_main_location(dt_map_t *lib,
1170
1170
if (!d )
1171
1171
{
1172
1172
d = g_malloc0 (sizeof (dt_location_draw_t ));
1173
- lib -> loc .others = g_list_append (lib -> loc .others , d );
1173
+ if (d )
1174
+ lib -> loc .others = g_list_append (lib -> loc .others , d );
1174
1175
}
1175
1176
if (d )
1176
1177
{
@@ -1545,52 +1546,58 @@ static void _view_map_changed_callback_delayed(gpointer user_data)
1545
1546
if (p [i ].cluster_id == NOISE )
1546
1547
{
1547
1548
dt_map_image_t * entry = (dt_map_image_t * )calloc (1 , sizeof (dt_map_image_t ));
1548
- entry -> imgid = p [i ].imgid ;
1549
- entry -> group = p [i ].cluster_id ;
1550
- entry -> group_count = 1 ;
1551
- entry -> longitude = p [i ].x * 180 / M_PI ;
1552
- entry -> latitude = p [i ].y * 180 / M_PI ;
1553
- entry -> group_same_loc = TRUE;
1554
- if (sel_imgs )
1555
- entry -> selected_in_group = g_list_find ((GList * )sel_imgs ,
1556
- GINT_TO_POINTER (entry -> imgid ))
1557
- ? TRUE : FALSE;
1558
- lib -> images = g_slist_prepend (lib -> images , entry );
1549
+ if (entry )
1550
+ {
1551
+ entry -> imgid = p [i ].imgid ;
1552
+ entry -> group = p [i ].cluster_id ;
1553
+ entry -> group_count = 1 ;
1554
+ entry -> longitude = p [i ].x * 180 / M_PI ;
1555
+ entry -> latitude = p [i ].y * 180 / M_PI ;
1556
+ entry -> group_same_loc = TRUE;
1557
+ if (sel_imgs )
1558
+ entry -> selected_in_group = g_list_find ((GList * )sel_imgs ,
1559
+ GINT_TO_POINTER (entry -> imgid ))
1560
+ ? TRUE : FALSE;
1561
+ lib -> images = g_slist_prepend (lib -> images , entry );
1562
+ }
1559
1563
}
1560
1564
else if (!processed [p [i ].cluster_id ])
1561
1565
{
1562
1566
processed [p [i ].cluster_id ] = TRUE;
1563
1567
group = p [i ].cluster_id ;
1564
1568
dt_map_image_t * entry = (dt_map_image_t * )calloc (1 , sizeof (dt_map_image_t ));
1565
- entry -> imgid = p [i ].imgid ;
1566
- entry -> group = p [i ].cluster_id ;
1567
- entry -> group_same_loc = TRUE;
1568
- entry -> selected_in_group = (sel_imgs && g_list_find ((GList * )sel_imgs ,
1569
- GINT_TO_POINTER (p [i ].imgid )))
1570
- ? TRUE : FALSE;
1571
- const double lon = p [i ].x , lat = p [i ].y ;
1572
-
1573
- for (int j = 0 ; j < img_count ; j ++ )
1569
+ if (entry )
1574
1570
{
1575
- if (p [j ].cluster_id == group )
1571
+ entry -> imgid = p [i ].imgid ;
1572
+ entry -> group = p [i ].cluster_id ;
1573
+ entry -> group_same_loc = TRUE;
1574
+ entry -> selected_in_group = (sel_imgs && g_list_find ((GList * )sel_imgs ,
1575
+ GINT_TO_POINTER (p [i ].imgid )))
1576
+ ? TRUE : FALSE;
1577
+ const double lon = p [i ].x , lat = p [i ].y ;
1578
+
1579
+ for (int j = 0 ; j < img_count ; j ++ )
1576
1580
{
1577
- entry -> group_count ++ ;
1578
- entry -> longitude += p [j ].x ;
1579
- entry -> latitude += p [j ].y ;
1580
- if (entry -> group_same_loc && (p [j ].x != lon || p [j ].y != lat ))
1581
+ if (p [j ].cluster_id == group )
1581
1582
{
1582
- entry -> group_same_loc = FALSE;
1583
- }
1584
- if (sel_imgs && !entry -> selected_in_group )
1585
- {
1586
- if (g_list_find ((GList * )sel_imgs , GINT_TO_POINTER (p [j ].imgid )))
1587
- entry -> selected_in_group = TRUE;
1583
+ entry -> group_count ++ ;
1584
+ entry -> longitude += p [j ].x ;
1585
+ entry -> latitude += p [j ].y ;
1586
+ if (entry -> group_same_loc && (p [j ].x != lon || p [j ].y != lat ))
1587
+ {
1588
+ entry -> group_same_loc = FALSE;
1589
+ }
1590
+ if (sel_imgs && !entry -> selected_in_group )
1591
+ {
1592
+ if (g_list_find ((GList * )sel_imgs , GINT_TO_POINTER (p [j ].imgid )))
1593
+ entry -> selected_in_group = TRUE;
1594
+ }
1588
1595
}
1589
1596
}
1597
+ entry -> latitude = entry -> latitude * 180 / M_PI / entry -> group_count ;
1598
+ entry -> longitude = entry -> longitude * 180 / M_PI / entry -> group_count ;
1599
+ lib -> images = g_slist_prepend (lib -> images , entry );
1590
1600
}
1591
- entry -> latitude = entry -> latitude * 180 / M_PI / entry -> group_count ;
1592
- entry -> longitude = entry -> longitude * 180 / M_PI / entry -> group_count ;
1593
- lib -> images = g_slist_prepend (lib -> images , entry );
1594
1601
}
1595
1602
}
1596
1603
free (processed );
@@ -3092,28 +3099,29 @@ static void _view_map_dnd_get_callback(GtkWidget *widget,
3092
3099
if (imgs_nb )
3093
3100
{
3094
3101
uint32_t * imgs = malloc (sizeof (uint32_t ) * imgs_nb );
3095
- int i = 0 ;
3096
- for (GList * l = lib -> selected_images ;
3097
- l ;
3098
- l = g_list_next (l ))
3102
+ if (imgs )
3099
3103
{
3100
- imgs [i ++ ] = GPOINTER_TO_INT (l -> data );
3104
+ int i = 0 ;
3105
+ for (GList * l = lib -> selected_images ;
3106
+ l ;
3107
+ l = g_list_next (l ))
3108
+ {
3109
+ imgs [i ++ ] = GPOINTER_TO_INT (l -> data );
3110
+ }
3111
+ gtk_selection_data_set (selection_data ,
3112
+ gtk_selection_data_get_target (selection_data ),
3113
+ _DWORD , (guchar * )imgs , imgs_nb * sizeof (uint32_t ));
3114
+ free (imgs );
3101
3115
}
3102
- gtk_selection_data_set (selection_data ,
3103
- gtk_selection_data_get_target (selection_data ),
3104
- _DWORD , (guchar * )imgs , imgs_nb * sizeof (uint32_t ));
3105
- free (imgs );
3106
3116
}
3107
3117
}
3108
3118
else if (lib -> loc .main .id > 0 )
3109
3119
{
3110
3120
// move of location
3111
- uint32_t * imgs = malloc (sizeof (uint32_t ));
3112
- imgs [0 ] = -1 ;
3121
+ uint32_t imgs [1 ] = { -1 };
3113
3122
gtk_selection_data_set (selection_data ,
3114
3123
gtk_selection_data_get_target (selection_data ),
3115
3124
_DWORD , (guchar * )imgs , sizeof (uint32_t ));
3116
- free (imgs );
3117
3125
}
3118
3126
}
3119
3127
break ;
@@ -3304,9 +3312,11 @@ static void _bin_points(const dt_map_t *lib,
3304
3312
// allocate pointers for all of the latitude bins at this
3305
3313
// longitude
3306
3314
db .geo_bins [lon_bin ] = (geo_bin_t * )calloc (num_lat_bins , sizeof (geo_bin_t ));
3307
-
3308
- for (int l = 0 ; l < num_lat_bins ; l ++ )
3309
- db .geo_bins [lon_bin ][l ].points = NO_NEXT_POINT ;
3315
+ if (db .geo_bins [lon_bin ])
3316
+ {
3317
+ for (int l = 0 ; l < num_lat_bins ; l ++ )
3318
+ db .geo_bins [lon_bin ][l ].points = NO_NEXT_POINT ;
3319
+ }
3310
3320
}
3311
3321
// push the point on the front of the linked list for its bin
3312
3322
db .points [i ].next = db .geo_bins [lon_bin ][lat_bin ].points ;
0 commit comments