void Gtk::Widget::get_preferred_width pass nullptr

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

void Gtk::Widget::get_preferred_width pass nullptr

Matthew Morgan
I'm using the function Gtk::Widget::get_preferred_width() in a program,
and I noticed something odd in it's documentation on
developer.gnome.org.  It specifies it this way:

void Gtk::Widget::get_preferred_width(int &minimum_width, int
&natural_width)
minimum_width    Location to store the minimum width, or nullptr.
natural_width    Location to store the natural width, or nullptr.

As I use it I really only want natural_width, but everything I read
indicates that passing a nullptr reference is invalid; in fact, I can't
even come up with code to do so that gcc will compile.  What is the
intended way to pass nullptr to this function?  For now I'm just giving
a real int to minimum_width and not using it.
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: void Gtk::Widget::get_preferred_width pass nullptr

Daniel Boles
The docs are autogenerated from the C documentation. Things like this aren't intelligently changed. (It's only more basic stuff like changing NULL to "nullptr").

It would be good if they were, but I don't know if anyone would want to try changing the doc processor to detect phrases like "or NULL" and drop them for reference args.

Yes, you just need to pass a reference to a real, 'dummy' int.

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: void Gtk::Widget::get_preferred_width pass nullptr

Daniel Boles
fwiw, of course, where you see this for std::string or Glib::ustring parameters, the empty string "" should usually suffice

I mention it because that's a pattern I think is much less subjective and therefore more reasonable for the doc processor to substitute, and I suggested that here: https://bugzilla.gnome.org/show_bug.cgi?id=785899

The problem with "blah blah, or NULL" is that it could be written in various slightly different ways, which would complicate detecting and removing it.

Maybe one day I'll learn enough to try it out just for a laugh, though. :D

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list