Glib::KeyFile bug?
- From: Damon Register <damonregister bellsouth net>
- To: gtkmm-list gnome org
- Subject: Glib::KeyFile bug?
- Date: Sat, 21 Jun 2008 08:37:36 -0400
I am attempting to use the Glib::KeyFile in my application. It actually
worked and the key values were extracted just as I expected. I wanted
to experiment so I copied my test app to another folder. I tampered and
then ran but it crashed with
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I realized that I had forgotten to copy the key file so I copied that to
the new test directory and then the program ran. I got a bit curious about
this so I looked at the glibmm reference for Glib::KeyFile::load_from_file
where it said that it would return false if the file could not be loaded.
I trimmed it down to a very simple gtkmm app that does nothing but create
an instance of KeyFile and call load_from_file. Still I found that the
program would die if the key file is not present. It is possible that I
am not understanding the reference material but I expect that the function
would just return false if the file is not present. In my example that
I have included, I expect to just get the cout output
file_success=0
Is this not correct? Is there a bug in Glib::KeyFile?
Damon Register
#include <gtkmm/window.h>
#include <gtkmm/main.h>
#include <gtkmm/stock.h>
#include <glibmm/keyfile.h>
#include <iostream>
class ExampleWindow : public Gtk::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
Glib::KeyFile* mykey;
};
ExampleWindow::ExampleWindow()
{
bool file_success = false;
set_title("KeyFile example");
show_all_children();
mykey = new Glib::KeyFile();
file_success = mykey->load_from_file( "hello.ini", Glib::KEY_FILE_NONE ); //NONE is default
std::cout << "file_success=" << file_success << std::endl;
}
ExampleWindow::~ExampleWindow()
{
delete mykey;
}
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
Gtk::Main::run(window);
return 0;
}
#The key file
# this is just an example
# there can be comments before the first group
[First Group]
Name=Key File Example\tthis value shows\nescaping
# localized strings are stored in multiple key-value pairs
Welcome=Hello
Welcome[de]=Hallo
Welcome[fr]=Bonjour
Welcome[it]=Ciao
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]