Giter VIP home page Giter VIP logo

gobject-tutorial's People

Contributors

evaporei avatar mingxingren avatar tclfs avatar toshiocp avatar travishaynes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gobject-tutorial's Issues

Example from section 2 results in SIGSEGV

Hello! First and foremost thanks for the tutorial you've made, it's helping me to understand how to use the GObject library (and how it works).

I tried running the second example in section 2 locally, and ran into an SIGSEGV (Address boundary error).

#include <glib-object.h>

static void
show_ref_count (GObject *instance) {
  if (G_IS_OBJECT (instance))
    /* Users should not use ref_count member in their program. */
    /* This is only for demonstration. */
    g_print ("Reference count is %d.\n", instance->ref_count);
  else
    g_print ("Instance is not GObject.\n");
}

int
main (int argc, char **argv) {
  GObject *instance;
  
  instance = g_object_new (G_TYPE_OBJECT, NULL);
  g_print ("Call g_object_new.\n");
  show_ref_count (instance);
  g_object_ref (instance);
  g_print ("Call g_object_ref.\n");
  show_ref_count (instance);
  g_object_unref (instance);
  g_print ("Call g_object_unref.\n");
  show_ref_count (instance);
  g_object_unref (instance);
  g_print ("Call g_object_unref.\n");
  show_ref_count (instance);
  
  return 0;
}

I've used gdb and the problem is at the last line show_ref_count (instance) after the instance has been freed. It doesn't even get into the function show_ref_count nor the G_IS_OBJECT call, it fails before at g_type_check_instance_is_fundamentally_a which I would guess happens when the instance pointer is copied into a function? ๐Ÿค” I'm not sure how that happens.

I don't know either if it's any problem with my local environment. In your page you mention that there are examples in the misc folder, but I couldn't find those here.

I'm using an Arch Linux and compiling via gcc with the following command:

gcc -g example.c -o example $(pkg-config --cflags --libs gobject-2.0)

If it is the case that my environment is correct and this error is reproducible, how does one check that an GObject * instance is null without calling any function using it? ๐Ÿค”

The documentation does not say what GObject "IS"

The documentation seems to only talk about how to use GObject and not what it is used for. It is a simple thing that demands research from casual readers trying to find footing. Two sentences should be sufficient.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.