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



Akbar wrote:

> Here's the code:
>
> string song, outputsong, s1;
> int songlength, outputsonglength;
> char* arg_list[10];
> const int file = 1;
> const int directory = 2;
>
> void window1::on_processing() {
> 	const int mp3 = 1, ogg = 2, no = 0;
> 	for(int ii=0; ii<10; ii++)
> 		arg_list[ii] = new char[100];
>
> 	int type;
> 	songlength = song.length();
>         string temp( song, 0, songlength-4 );
>         outputsong = temp;
> 	outputsonglength = outputsong.length();
>         s1 = song.substr(outputsonglength+1,3) ;
>
> 	if(s1=="mp3") type = mp3;	
> 	
> 	else if(s1=="ogg") type = ogg;
>
> 	else type = no;
>
>         switch(type) {
> 		case mp3: do_mp3();
> 		 	  break;
> 	        case ogg: do_ogg();
> 			  break;
> 		default:
> 			  break;
> 	}
>
>         for(int i=0; i<10; i++)
>                	delete arg_list[i];
> }
>
> void do_ogg() {
> 	if( fork() == 0 ) {
> 		int child;
> 		arg_list[0] = "oggdec";
> 		song.copy( arg_list[1], songlength, 0 );
> 		arg_list[1][songlength] = '\0';
> 		arg_list[2] = NULL;
> 		spawn( "oggdec", arg_list );
> 		wait(&child);
> 		arg_list[0] = "lame";
> 		outputsong += ".wav";
> 		outputsong.copy( arg_list[1], outputsonglength+4, 0 );
> 		arg_list[1][outputsonglength+4] = '\0';
> 		outputsong = outputsong.substr( 0, outputsonglength );
> 		arg_list[2] = NULL;
> 		spawn( "lame", arg_list );
> 		wait(&child);
> 		arg_list[0] = "rm";
> 		spawn( "rm", arg_list );
> 		wait(&child);
> 		delete arg_list[2];
> 		arg_list[2] = new char[100];
> 		arg_list[0] = "mv";
> 		string temp = outputsong + ".wav" + ".mp3";
> 		temp.copy( arg_list[1], outputsonglength+8, 0 );
> 		arg_list[1][outputsonglength+8] = '\0';
> 		outputsong += ".mp3";
> 		outputsong.copy( arg_list[2], outputsonglength+4, 0 );
> 		arg_list[2][outputsonglength+4] = '\0';
> 		arg_list[3] = NULL;
> 		spawn( "mv", arg_list );
> 		wait(&child);
> 		_exit( 0 );
> 	}
> }
>
> void do_mp3() {
> 	if( fork() == 0 ) {
>              int child;
> 	     arg_list[0] = "mpg321";
> 	     song.copy( arg_list[1], songlength, 0 );
> 	     arg_list[1][songlength] = '\0';
> 	     arg_list[2] = "-w";
> 	     outputsong.copy( arg_list[3], outputsonglength, 0 );
> 	     arg_list[3][outputsonglength] = '\0';
> 	     arg_list[4] = NULL;
> 	     spawn("mpg321", arg_list);
> 	     wait(&child);
> 	     arg_list[0] = "oggenc";
> 	     outputsong.copy( arg_list[1], outputsonglength, 0 );
> 	     arg_list[1][outputsonglength] = '\0';
> 	     arg_list[2] = NULL;
> 	     spawn("oggenc", arg_list);
> 	     wait(&child);
> 	     arg_list[0] = "rm";
> 	     outputsong.copy( arg_list[1], outputsonglength, 0 );
> 	     spawn("rm", arg_list);
> 	     wait(&child);
> 	     _exit( 0 );
> 	}
> }
>
> As you can see, none of my child processes talk to GUI. Any idea?

Not really, no, unless just forking a process with a GUI in it is enough to cause problems, which it might be. You could try modifying a hello world type gtkmm programme so that it forks under similar circumstances, and see what happens - that might tell you if it's the forking or something else that's going wrong.




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