Hi, I have 2 .ui files. One is the main and the other is the preferences window(this is actually a QDialog). In the constructor of the preferences window i have added this code to check if the second line of a file contains the char "1". Unfortunately then the program craches (this is the reason for sure, because when I comment this piece of source then it works fine...
This is the source:
char homee[150]="/home/";
strcat(homee,py); //py is the current logged on user
char otherr[100]="/.config/on_launch_enabled_options";
strcat(homee,otherr);
char line [ 128 ];
int i;
FILE *file = fopen ( homee, "r" );
for ( i = 0; i < 1; ++i )
{
fgets ( line, sizeof line, file ); }
fclose ( file );
if(!strcmp (line,"1\n"))
ui->checkminimizeonlaunch->setCheckState(Qt::Checked); else ui->checkminimizeonlaunch->setCheckState(Qt::Unchecked);
char homee[150]="/home/";
strcat(homee,py); //py is the current logged on user
char otherr[100]="/.config/on_launch_enabled_options";
strcat(homee,otherr);
char line [ 128 ];
int i;
FILE *file = fopen ( homee, "r" );
for ( i = 0; i < 1; ++i )
{
fgets ( line, sizeof line, file ); }
fclose ( file );
if(!strcmp (line,"1\n"))
ui->checkminimizeonlaunch->setCheckState(Qt::Checked); else ui->checkminimizeonlaunch->setCheckState(Qt::Unchecked);
To copy to clipboard, switch view to plain text mode
Thx for any replies.
Notice that if I do the same thing in a Qt-console application it works fine
(changing ui->checkminimizeonlaunch->setCheckState(Qt::Checked); else ui->checkminimizeonlaunch->setCheckState(Qt::Unchecked); to cout << "Strings Are similar\n"; )
It crushes exactly at the point it says fgets ( line, sizeof line, file );
Bookmarks