After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 545050 - GTraverseFlags wrapping is wrong
GTraverseFlags wrapping is wrong
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
2.17.x
Other All
: Normal major
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2008-07-27 22:35 UTC by Szilárd Pfeiffer
Modified: 2008-08-01 09:14 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
possible solution (687 bytes, patch)
2008-07-27 22:37 UTC, Szilárd Pfeiffer
none Details | Review
move the TraverseFlags to the right place (1.32 KB, patch)
2008-07-29 22:38 UTC, Szilárd Pfeiffer
none Details | Review
move the TraverseFlags to the right place (1.12 KB, patch)
2008-07-29 22:45 UTC, Szilárd Pfeiffer
none Details | Review

Description Szilárd Pfeiffer 2008-07-27 22:35:22 UTC
Please describe the problem:
The flag Glib::TRAVERSE_ALL equals to Glib::TRAVERSE_LEAVES instead of  Glib::TRAVERSE_LEAVES | Glib::G_TRAVERSE_NON_LEAVES

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Szilárd Pfeiffer 2008-07-27 22:37:03 UTC
Created attachment 115395 [details] [review]
possible solution

Possible solution of the problem has attached
Comment 2 Murray Cumming 2008-07-28 16:19:39 UTC
Eek. Where is this enum used?
Comment 3 Szilárd Pfeiffer 2008-07-28 18:33:55 UTC
(In reply to comment #2)
> Eek. Where is this enum used?
> 

Nowhere. I found this problem when I was testing my patch (bug 520778 comment 23).
Comment 4 Murray Cumming 2008-07-29 10:46:21 UTC
Thanks.

Because this is not used anywhere else, we can just hand-code this enum in the class anyway, giving us the chance to do it correctly, and allowing us to omit the deprecated LEAFS mispellings.

I have done that in svn.
Comment 5 Szilárd Pfeiffer 2008-07-29 22:37:12 UTC
I am afraid the TraversFlags enum inserted to a wrong place (not exactly to the Glib namespace).
Comment 6 Szilárd Pfeiffer 2008-07-29 22:38:41 UTC
Created attachment 115526 [details] [review]
move the TraverseFlags to the right place
Comment 7 Szilárd Pfeiffer 2008-07-29 22:45:43 UTC
Created attachment 115528 [details] [review]
move the TraverseFlags to the right place
Comment 8 Murray Cumming 2008-07-30 06:51:55 UTC
It's meant to be inside NodeTree, because it is not used anywhere else.
Comment 9 Szilárd Pfeiffer 2008-07-30 21:55:07 UTC
(In reply to comment #8)
> It's meant to be inside NodeTree, because it is not used anywhere else.
> 

It is not used, but it will be, just like in case of TraverseType.
If I made the following change in the test file it would cause compilation problem (without attachment 115528 [details] [review]):

--- tests/glibmm_nodetree/main.cc	(revision 704)
+++ tests/glibmm_nodetree/main.cc	(working copy)
@@ -54,7 +54,7 @@
   std::cout << std::endl;
 
   std::cout << "Leaf children of 'a':" << std::endl;
-  ta.foreach(sigc::bind<bool>(sigc::ptr_fun(echol), true));
+  ta.foreach(sigc::bind<bool>(sigc::ptr_fun(echol), true), Glib::TRAVERSE_ALL);
   std::cout << std::endl;
 
   std::cout << "Non-leaf children of 'a':" << std::endl;


error message of gcc:

main.cc: In function ‘int main()’:
main.cc:57: error: ‘TRAVERSE_ALL’ is not a member of ‘Glib’
Comment 10 Jonathon Jongsma 2008-07-31 02:04:40 UTC
you should use Glib::NodeTree::TRAVERSE_ALL
Comment 11 Murray Cumming 2008-07-31 07:22:56 UTC
> > It's meant to be inside NodeTree, because it is not used anywhere else.
> It is not used, but it will be,

The C enum is not used anywhere else, so I doubt that.

> If I made the following change in the test file it would cause compilation
> problem (without attachment 115528 [details] [review] [edit]):

Obviously, because it should be Glib::TreeNode<std::string>::TRAVERSE_ALL. I agree that is not pretty, but you should be using a typedef for the TreeNode to simplify your code anyway.
Comment 12 Szilárd Pfeiffer 2008-07-31 08:49:25 UTC
(In reply to comment #10)
> you should use Glib::NodeTree::TRAVERSE_ALL
> 

Thanks. I really know it, but I don't understand it. Is it a good idea to handle similar enums (TraverseType, TraverseFlags) in a different way (point of namesapces) ?
Comment 13 Szilárd Pfeiffer 2008-07-31 08:57:14 UTC
(In reply to comment #11)
> > > It's meant to be inside NodeTree, because it is not used anywhere else.
> > It is not used, but it will be,
> 
> The C enum is not used anywhere else, so I doubt that.
> 
> > If I made the following change in the test file it would cause compilation
> > problem (without attachment 115528 [details] [review] [edit] [edit]):
> 
> Obviously, because it should be Glib::TreeNode<std::string>::TRAVERSE_ALL. I
> agree that is not pretty, but you should be using a typedef for the TreeNode to
> simplify your code anyway.
> 

I agree taht it is not so pretty, because in compile time different enum will be generated for each and every different Glib::NodeTree<T> depending on T.
Comment 14 Murray Cumming 2008-07-31 11:22:03 UTC
Where an enum is used by only one class, then, yes, that enum should be in the class. That makes it more self-documenting.

We would do this with more enums, but _WRAP_ENUM() doesn't do that for us yet:
http://bugzilla.gnome.org/show_bug.cgi?id=86864

I would like the two enums to have different prefixes for their values, but I can't think of good ones.
Comment 15 Szilárd Pfeiffer 2008-07-31 15:21:37 UTC
(In reply to comment #14)
> Where an enum is used by only one class, then, yes, that enum should be in the
> class. That makes it more self-documenting.
> 
> We would do this with more enums, but _WRAP_ENUM() doesn't do that for us yet:
> http://bugzilla.gnome.org/show_bug.cgi?id=86864
> 
> I would like the two enums to have different prefixes for their values, but I
> can't think of good ones.
> 

I see. The concept is pretty good. The only thing which disturbs me is the inconsistency (comment 12). Otherwise in case of a template class each enums which defined in the class will be different types (depending on T). In my humble opinion it is worth considering that (maybe it's not a big deal).
Comment 16 Murray Cumming 2008-08-01 09:14:55 UTC
> in case of a template class each enums
> which defined in the class will be different types (depending on T). In my
> humble opinion it is worth considering that (maybe it's not a big deal).

Two specializations of the template can't be used polymorphically (there's no base class) so I don't see a real problem with this. Generic use of the types would be via a template, which would allow use of the templated typename.

Closing for now. But please reopen if you can suggest an improvement. Thanks for the vigilance.