Skip to content
Snippets Groups Projects
Commit 39cfd20e authored by Theo Linkspfeifer's avatar Theo Linkspfeifer :speech_balloon: Committed by Alexander Schwinn
Browse files

Replace 'thunar_return_if_fail (THUNAR_IS_DEVICE (device))' with

standard 'if (..)' to prevent possible crashes. (Bug #13404)

('_thunar_return_if_fail' will only be executed when compiled with
debugging enabled. )

'THUNAR_IS_DEVICE()' will be used over 'device != NULL', since that call
does a bit more than checking for NULL.

Co-authored-by: Alexander Schwinn's avatarAlexander Schwinn <alexxcons@xfce.org>
parent 1234b759
No related branches found
No related tags found
No related merge requests found
......@@ -1799,7 +1799,7 @@ thunar_shortcuts_view_open (ThunarShortcutsView *view,
THUNAR_SHORTCUTS_MODEL_COLUMN_LOCATION, &location,
-1);
if (G_LIKELY (device != NULL))
if (G_LIKELY (THUNAR_IS_DEVICE (device)))
{
/* start the spinner */
child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
......@@ -1886,18 +1886,20 @@ thunar_shortcuts_view_create_shortcut (ThunarShortcutsView *view)
{
/* determine the device/mount for the shortcut at the given tree iterator */
gtk_tree_model_get (model, &iter, THUNAR_SHORTCUTS_MODEL_COLUMN_DEVICE, &device, -1);
_thunar_return_if_fail (THUNAR_IS_DEVICE (device));
/* add the mount point to the model */
mount_point = thunar_device_get_root (device);
if (mount_point != NULL)
if (G_LIKELY (THUNAR_IS_DEVICE (device)))
{
shortcuts_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
thunar_shortcuts_model_add (THUNAR_SHORTCUTS_MODEL (shortcuts_model), NULL, mount_point);
g_object_unref (mount_point);
}
/* add the mount point to the model */
mount_point = thunar_device_get_root (device);
if (mount_point != NULL)
{
shortcuts_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
thunar_shortcuts_model_add (THUNAR_SHORTCUTS_MODEL (shortcuts_model), NULL, mount_point);
g_object_unref (mount_point);
}
g_object_unref (G_OBJECT (device));
g_object_unref (G_OBJECT (device));
}
}
}
......@@ -1953,24 +1955,26 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view)
{
/* determine the device/mount for the shortcut at the given tree iterator */
gtk_tree_model_get (model, &iter, THUNAR_SHORTCUTS_MODEL_COLUMN_DEVICE, &device, -1);
_thunar_return_if_fail (THUNAR_IS_DEVICE (device));
/* prepare a mount operation */
mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view));
if (G_LIKELY (THUNAR_IS_DEVICE (device)))
{
/* prepare a mount operation */
mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view));
/* start the spinner */
child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
thunar_shortcuts_model_set_busy (THUNAR_SHORTCUTS_MODEL (child_model), device, TRUE);
/* start the spinner */
child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
thunar_shortcuts_model_set_busy (THUNAR_SHORTCUTS_MODEL (child_model), device, TRUE);
/* try to unmount */
thunar_device_eject (device,
mount_operation,
NULL,
thunar_shortcuts_view_eject_finish,
g_object_ref (view));
/* try to unmount */
thunar_device_eject (device,
mount_operation,
NULL,
thunar_shortcuts_view_eject_finish,
g_object_ref (view));
g_object_unref (G_OBJECT (device));
g_object_unref (G_OBJECT (mount_operation));
g_object_unref (G_OBJECT (device));
g_object_unref (G_OBJECT (mount_operation));
}
}
}
......@@ -2030,7 +2034,7 @@ thunar_shortcuts_view_mount (ThunarShortcutsView *view)
/* determine the file for the shortcut at the given tree iterator */
gtk_tree_model_get (model, &iter, THUNAR_SHORTCUTS_MODEL_COLUMN_DEVICE, &device, -1);
if (G_LIKELY (device != NULL))
if (G_LIKELY (THUNAR_IS_DEVICE (device)))
{
/* start the spinner */
child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
......@@ -2096,24 +2100,26 @@ thunar_shortcuts_view_unmount (ThunarShortcutsView *view)
{
/* determine the device/mount for the shortcut at the given tree iterator */
gtk_tree_model_get (model, &iter, THUNAR_SHORTCUTS_MODEL_COLUMN_DEVICE, &device, -1);
_thunar_return_if_fail (THUNAR_IS_DEVICE (device));
/* prepare a mount operation */
mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view));
if (G_LIKELY (THUNAR_IS_DEVICE (device)))
{
/* prepare a mount operation */
mount_operation = thunar_gtk_mount_operation_new (GTK_WIDGET (view));
/* start the spinner */
child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
thunar_shortcuts_model_set_busy (THUNAR_SHORTCUTS_MODEL (child_model), device, TRUE);
/* start the spinner */
child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
thunar_shortcuts_model_set_busy (THUNAR_SHORTCUTS_MODEL (child_model), device, TRUE);
/* try to unmount */
thunar_device_unmount (device,
mount_operation,
NULL,
thunar_shortcuts_view_unmount_finish,
g_object_ref (view));
/* try to unmount */
thunar_device_unmount (device,
mount_operation,
NULL,
thunar_shortcuts_view_unmount_finish,
g_object_ref (view));
g_object_unref (G_OBJECT (device));
g_object_unref (G_OBJECT (mount_operation));
g_object_unref (G_OBJECT (device));
g_object_unref (G_OBJECT (mount_operation));
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment