gdb: Move value_from_host_double into value.c and make more use of it
[deliverable/binutils-gdb.git] / gdb / python / py-infthread.c
index 36ae71b635817f3b03d439f540515f9e10d3cb21..bf90d08ae6e9241a085d8817ef00c91a1414de1b 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to inferior threads.
 
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -41,12 +41,16 @@ create_thread_object (struct thread_info *tp)
 {
   thread_object *thread_obj;
 
+  gdbpy_ref<inferior_object> inf_obj = inferior_to_inferior_object (tp->inf);
+  if (inf_obj == NULL)
+    return NULL;
+
   thread_obj = PyObject_New (thread_object, &thread_object_type);
   if (!thread_obj)
     return NULL;
 
   thread_obj->thread = tp;
-  thread_obj->inf_obj = (PyObject *) inferior_to_inferior_object (tp->inf);
+  thread_obj->inf_obj = (PyObject *) inf_obj.release ();
 
   return thread_obj;
 }
@@ -284,15 +288,7 @@ PyObject *
 gdbpy_selected_thread (PyObject *self, PyObject *args)
 {
   if (inferior_ptid != null_ptid)
-    {
-      PyObject *thread_obj
-       = (PyObject *) thread_to_thread_object (inferior_thread ());
-      if (thread_obj != NULL)
-       {
-         Py_INCREF (thread_obj);
-         return thread_obj;
-       }
-    }
+    return thread_to_thread_object (inferior_thread ()).release ();
 
   Py_RETURN_NONE;
 }
This page took 0.023865 seconds and 4 git commands to generate.