[gtkmm] BadWindow ( invalid Window parameter ) / Gtk::Dialog hell for newbie



I try to make front-end using gktmm library and glade. I use gtkmm 2.2
and glade 2.0.0. My program will convert ogg files to mp3 files and vice
versa. It works great but only for one file. I always get this error
when I want to convert all files in one directory:


The program 'converter' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
  (Details: serial 2703 error_code 3 request_code 4 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error()
function.)

I am newbie so don't expect me to understand this error. Ok here's the
detail:
I got Gtk::Entry entry to hold the file or directory that user want to
convert. If the case is file, it is easy. If the file is
/home/knight/Music/blabla.mp3, my program will convert it to blabla.ogg
file. if the file is /home/knight/Music/blabla.ogg, my program will
convert it to mp3 file. But if the case is directory, it is not easy
anymore. It is hell for me. :( 

Assume entry hold this value: /home/knight/Music. Just for note, I set
entry value using Gtk::FileSelection class. If my user push the
Gtk::Button convert, my program will confuse. What files must it
convert? mp3 to ogg or ogg to mp3? 

Then I make Gtk::Dialog dialog. Here's the code. If you push the button,
this function will work:

void window1::on_convert_clicked()
{  
	if(status==1) {             //if the case is file
	song = input->get_text();
        on_processing();
	}
	else if(status==2) {        //if the case is directory

                //Ok, look over here: I make a dialog. The dialog for 
                //this mailing list purpose will consist only two 
                //button; ogg and mp3
		Gtk::Dialog *dialog;
		dialog = new class Gtk::Dialog("bla bla", *this ) ;
                dialog->add_button("ogg",1);
		dialog->add_button("mp3",2);

		int bla;
		bla = dialog->run();

		DIR *d;
	        struct dirent *dir;


		delete dialog;


		Glib::ustring Direct = input->get_text();
	        d = opendir(Direct.c_str());
	        string temp;
	        vector<string> files;
		switch(bla) {
			case 1: 
		                if(d) {
			                while((dir = readdir(d))) {
						temp = dir->d_name;
						if(temp.length()>=4)
					               if(temp.substr(temp.length()-4,4)==".ogg")	
						                files.push_back(temp);
					}
				}
				break;
			case 2: 
				if(d) {
					while((dir = readdir(d))) {
						temp = dir->d_name;
						if(temp.length()>=4)
						       if(temp.substr(temp.length()-4,4)==".mp3")
						        	files.push_back(temp);
					}
				}
				break;
			default:
				break;
		}
		int child;
		if(fork()==0) 
		     for( int i=0; i<files.size(); i++ ) {
		        	song = Direct + "/" + files[i];
		        	on_processing();
				wait(&child);
		     }
	}
}


But if I push the ogg or mp3 button in Gtk::Dialog dialog, I get this
message:
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
  (Details: serial 2703 error_code 3 request_code 4 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error()
function.)

If I comment the delete dialog statement, I got this error:
Xlib: unexpected async reply (sequence 0x24ff)!

Please, tell me what's wrong!!!!
Here's my gdb sessing after fork() function statement:

Breakpoint 2, window1::on_convert_clicked (this=0x80834c8) at
window1.cc:307
307                     if(fork()==0)
(gdb) n
Detaching after fork from child process 7052.
101         { for ( ; __first != __last; ++__first) _Destroy(&*__first);
}
(gdb) n
130           _M_deallocate(_Tp* __p, size_t __n) {
_Alloc_type::deallocate(__p,  __n);}
(gdb) n
242           { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof
(_Tp)); }
(gdb) n
249           { return  _M_dataplus._M_p; }
(gdb) n
38      {
(gdb) n
40        __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}"
(gdb) n
38      {
(gdb) n
207                 _M_destroy(__a);
(gdb) n
656           ~allocator() throw() {}
(gdb) n
314     }
(gdb) n
0x08053a27 in SigC::ObjectSlot0_<void, window1_glade>::proxy
(s=0x8106580)
    at object_slot.h:62
62              return ((Obj*)(os->object_)
(gdb) n
Glib::SignalProxyNormal::slot0_void_callback (self=0x80ad160,
data=0x81065b0)
    at signalproxy.cc:108
108     signalproxy.cc: No such file or directory.
        in signalproxy.cc
(gdb) n
0x40760d27 in g_cclosure_marshal_VOID__VOID ()
   from /usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_cclosure_marshal_VOID__VOID,
which has no line number information.
0x4074dea7 in g_closure_invoke () from /usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_closure_invoke,
which has no line number information.
0x4074e3d0 in g_signal_type_cclosure_new () from
/usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_signal_type_cclosure_new,
which has no line number information.
0x4074dee0 in g_closure_invoke () from /usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_closure_invoke,
which has no line number information.
0x407607d6 in g_signal_emit_by_name () from
/usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_signal_emit_by_name,
which has no line number information.
0x40761e40 in g_cclosure_marshal_BOOLEAN__FLAGS ()
   from /usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function
g_cclosure_marshal_BOOLEAN__FLAGS,
which has no line number information.
0x407604dd in g_signal_emit_by_name () from
/usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_signal_emit_by_name,
which has no line number information.
0x40761e40 in g_cclosure_marshal_BOOLEAN__FLAGS ()
   from /usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function
g_cclosure_marshal_BOOLEAN__FLAGS,
which has no line number information.
0x40760627 in g_signal_emit_by_name () from
/usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_signal_emit_by_name,
which has no line number information.
0x4075f958 in g_signal_emit_valist () from
/usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_signal_emit_valist,
which has no line number information.
0x4075fb94 in g_signal_emit () from /usr/lib/./libgobject-2.0.so.0
(gdb) n
Single stepping until exit from function g_signal_emit,
which has no line number information.
0x40314a5b in gtk_button_clicked () from /usr/lib/./libgtk-x11-2.0.so.0
(gdb) n
Single stepping until exit from function gtk_button_clicked,
which has no line number information.
0x40315a4b in _gtk_button_paint () from /usr/lib/./libgtk-x11-2.0.so.0
(gdb) n
Single stepping until exit from function _gtk_button_paint,
which has no line number information.
0x40316110 in _gtk_button_set_depressed () from
/usr/lib/./libgtk-x11-2.0.so.0
(gdb) n
Single stepping until exit from function _gtk_button_set_depressed,
which has no line number information.
The program 'converter' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
  (Details: serial 2701 error_code 3 request_code 10 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error()
function.)


Thank you!!!!



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]