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 371487 - Gnome::Vfs::DirectoryHandle::list_load has wrong signature
Gnome::Vfs::DirectoryHandle::list_load has wrong signature
Status: RESOLVED OBSOLETE
Product: gnome-vfsmm
Classification: Deprecated
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2006-11-06 11:55 UTC by Maik Beckmann
Modified: 2011-01-16 23:36 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
patch which fixes this bug (6.99 KB, patch)
2006-11-09 16:51 UTC, Maik Beckmann
none Details | Review

Description Maik Beckmann 2006-11-06 11:55:11 UTC
Hello

The following static member-function of Gnome::Vfs::DirectoryHandle:
<directory-handle.h>
static void list_load(const Glib::ListHandle<Glib::ustring>& list,
                      const Glib::ustring& text_uri, 
                      FileInfoOptions info_options) throw(exception);
</directory-handle.h>
seems to be useless.
 
See this little example program:
<code>
#include <libgnomevfsmm.h>
#include <iostream>
#include <list>

int main(int argc, char** argv)
{
    Gnome::Vfs::init();

    std::list<Glib::ustring>        list;
    Glib::ListHandle<Glib::ustring> listHandle(list);
    Gnome::Vfs::DirectoryHandle::list_load(
        listHandle,
        "ftp://ftp.gnome.org",
        Gnome::Vfs::FILE_INFO_DEFAULT );
    
    std::cout << list.size() << std::endl; 

    // ------------------------------
    GList* glist;
    gnome_vfs_directory_list_load(
        &glist, 
        "ftp://ftp.gnome.org",               
static_cast<GnomeVFSFileInfoOptions>(Gnome::Vfs::FILE_INFO_DEFAULT) );
   
    std::cout << g_list_length(glist) << std::endl; // prints: 17
    GnomeVFSFileInfo* info =
static_cast<GnomeVFSFileInfo*>(g_list_nth_data(glist,5));
    std::cout << info->name << std::endl;
    
    return 0;
}
</code>

<output>
0
17
conspiracy
</output>

The GList holds pointers GnomeVFSFileInfo structures, so Glib::ustring
being ListHandle-type makes no sense.


Maik Beckmann


<doc-links>
- Glib::ListHandle http://gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1ListHandle.html
- Gnome::Vfs::DirectoryHandle http://www.gtkmm.org/gnomemm2/reference/html/classGnome_1_1Vfs_1_1DirectoryHandle.html
- gnome_vfs_directory_list_load http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-20-gnome-vfs-directory-list-ops.html#gnome-vfs-directory-list-load
<doc-links>
Comment 1 Maik Beckmann 2006-11-06 14:31:09 UTC
Hello Again

I worked on this issue, but didn't solve it yet.

I want to comment to points

1. The interface
2. Implementation
3. Is a ListHandle object mutable?

############################

###
1. The interface

Since Gnome::Vfs::FileInfo is a reference counted type 
<doc-link>
http://www.gtkmm.org/gnomemm2/reference/html/classGnome_1_1Vfs_1_1FileInfo.html
</doc-link>
the Interface should IMHO look like this:
<directory-handle.h>
// We are inside namespace Gnome::Vfs and class-definition DirectoryHandle
static void list_load( Glib::ListHandle<Glib::RefPtr<FileInfo> >& list, 
                       const Glib::ustring& text_uri,
                       FileInfoOptions info_options )    throw(exception);
</directory-handle.h>
Note: The ListHandle isn't const anymore, since we want to alter the GList it wraps.
(Why isn't FileInfoOptions const?)

###
2. Implementation

If we alter the interface only, it would look like this
<directory-handle.cc>
static void 
DirectoryHandle::list_load( Glib::ListHandle<Glib::RefPtr<FileInfo> >& list, 
                            const Glib::ustring& text_uri,
                            FileInfoOptions info_options )    throw(exception);
{
  GList* temp_list = list.data();
  GnomeVFSResult result = 
    gnome_vfs_directory_list_load( 
                          &temp_list, 
                          text_uri.c_str(),   
                          static_cast<GnomeVFSFileInfoOptions>(info_options) );
  handle_result(result);
}
</directory-handle.cc>
but didn't work though.
The line
<code>
GList* temp_list = list.data();
</code>
itents to use temp_list for altering the the GList ListHandle holds. But the following line
<code>
gnome_vfs_directory_list_load( 
                          &temp_list, // temp_list itself will be altered 
                          text_uri.c_str(),   
                          static_cast<GnomeVFSFileInfoOptions>(info_options) );
</code>
alters the variable temp_list, not the object it points to. 
(I notized this by using ddd for debugging) 

###
3. Is a ListHandle object mutable?

If you look at the ListHandle documentation
<doc-link>
http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1ListHandle.html
</doc-link>
you'll see that all member functions are const. This brings up the question:
- Is a ListHandle object mutable? 

If not the interface has to look like this
<code>
static  Glib::ListHandle<Glib::RefPtr<FileInfo> > 
list_load( const Glib::ustring& text_uri,
           /* const? */FileInfoOptions info_options )    throw(exception) ;
</code>


Regards, Maik

Comment 2 Maik Beckmann 2006-11-06 14:59:19 UTC
I'm thinking about something like this:

<code>
#include <libgnomevfsmm.h>
#include <iostream>
#include <list>

Glib::ListHandle<Glib::RefPtr<Gnome::Vfs::FileInfo> >
list_load( const Glib::ustring& text_uri,
           const Gnome::Vfs::FileInfoOptions info_options) // throw(exception) 
{
    typedef Glib::ListHandle<Glib::RefPtr<Gnome::Vfs::FileInfo> > ret_t;

    GList* temp_list;
    GnomeVFSResult result =
        gnome_vfs_directory_list_load( &temp_list,
                                       text_uri.c_str(),
                                       static_cast<GnomeVFSFileInfoOptions>(info_options) );

    //handle_result(result);
    return ret_t(temp_list, Glib::OWNERSHIP_SHALLOW); // ...
    // ...I'm not sure about the right ownership!!

}

int main(int argc, char** argv)
{
    Gnome::Vfs::init();

    typedef
        Glib::ListHandle<Glib::RefPtr<Gnome::Vfs::FileInfo> >
        list_t ;

    list_t listHandle = list_load( "ftp://ftp.gnome.org/",
                                    Gnome::Vfs::FILE_INFO_DEFAULT );

    listHandle.begin();

    for (list_t::const_iterator it=listHandle.begin(); it!= listHandle.end(); ++it)
    {
        std::cout << (*it)->get_name() << std::endl;
    }



    return 0;
}
</code>

please spend your 2 cents

Maik
Comment 3 Murray Cumming 2006-11-06 17:02:34 UTC
> Glib::ListHandle<Glib::RefPtr<Gnome::Vfs::FileInfo> >
> list_load( const Glib::ustring& text_uri,
           const Gnome::Vfs::FileInfoOptions info_options) // throw(exception) 

This looks fine, though the const for info_options is meaningless (the parameter  is passed by value) and should be removed.

Could you submit a patch, please, now that you seem to have figured out how this should work. That's easier for me to review and test. Many thanks.
Comment 4 Maik Beckmann 2006-11-06 18:00:59 UTC
Ok!
I would like to add some test cases and run them before sending a patch, so please be patient until the weekend.

Maik

PS: const-correcting a value arg is indeed... ;o) 
    Thanks for the hint Murray.
Comment 5 Maik Beckmann 2006-11-09 16:51:26 UTC
Created attachment 76285 [details] [review]
patch which fixes this bug

I changed the function for --disable-api-exceptions too, but didn't test if it compiles, since my glibmm version uses exceptions.

Since there is no testing framework at all, I omitted the test cases. 

Doxygen docs has been added to the both function decleations, with and without exceptions. 

Note: Doxygen always generates for the "--disable-api-exceptions" case for all. So work has to be done to change this.

Regards, Maik
Comment 6 Maik Beckmann 2006-11-28 10:04:22 UTC
Will the patch be applied?

Maik
Comment 7 Murray Cumming 2006-11-28 20:51:25 UTC
Sorry for the delay. I will probably deprecate the existing method and add your new method, because we can't just change an existing method without breaking ABI. 

Or maybe there can not possibly be anybody using this method because it is useless/broken as is, so maybe it's OK to just change it.

But I will do at least something with this soon. Many thanks for taking care of this.
Comment 8 Murray Cumming 2008-02-10 16:40:31 UTC
I'm thinking of just ignoring this because giomm replaces gnome-vfsmm. Would that make life difficult for you?
Comment 9 Murray Cumming 2008-04-11 09:48:06 UTC
Yeah, moving to giomm is the best solution, and it's not that difficult.