You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

blu fire

Beginner

  • "blu fire" started this thread

Posts: 20

Location: London

Occupation: Student

  • Send private message

1

Thursday, August 26th 2004, 8:34pm

Segmentation fault

I have the following code:

Source code

1
2
3
4
5
void Window::init() {
  watch = new KDirWatch(0, "sprite");
  watch->addFile("../shared/position.dat");
  connect(watch, SIGNAL(dirty(const QString &)), this, SLOT(filedirty(const QString &)));
}

For some reason this compiles but causes a segmentation fault. I have exactly the same code in another file but it works fine.
Any ideas?

hatulflezet

Beginner

Posts: 14

Location: Germany

Occupation: Programmer

  • Send private message

2

Friday, August 27th 2004, 8:09am

IF indeed the segmantation accours in init() then the only thing that can go wrong is the allocation to KDirWatch, but I doubt that - how do oou know the segmentation is in init()?
Did you run it under a debugger, or with valgrind?
Click here! I dare ya'!! :]
Project Archimedes
----------------------------------------------------------
"Don't panic, and thanks for all the fish!"

blu fire

Beginner

  • "blu fire" started this thread

Posts: 20

Location: London

Occupation: Student

  • Send private message

3

Friday, August 27th 2004, 11:12am

Commenting out everything there stops the segmentation fault.

blu fire

Beginner

  • "blu fire" started this thread

Posts: 20

Location: London

Occupation: Student

  • Send private message

4

Friday, August 27th 2004, 11:25am

I just read the "tray icon" post and someone had a similar problem. It was suggested using KApplication instead of QApplication. Did that, and the program compiled but complained it was missing KCmdLineArgs::init(). Added all that information and it compiled and worked fine :D