LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 12-08-2007, 09:31 PM   #1
binarybob0001
Member
 
Registered: Dec 2004
Distribution: Debian Wheezy
Posts: 441

Rep: Reputation: 30
qt segmentation fault


Well, I can't be sure it's not my own files, but would one of you experts take a look at this code and see if there is cause for a segmentation fault. I have tried tracing it do the cerr statements but the fault seems to occur on the return of the call to down(QListViewItem* lvi, const QPoint& p, int col).
Code:
#include "FileView.h"
#include <iostream>

QFileView::QFileView()
{
  lv = new QListView(this);
  lv->addColumn( "File" );
  lv->addColumn( "Owner" ); 
  lv->addColumn( "Group" );
  lv->addColumn( "Permissions" ); 

  populate();
  bup = new QPushButton("Up", this);
  connect(bup, SIGNAL(clicked()), this, SLOT(up()) );
  connect(lv, SIGNAL(doubleClicked( QListViewItem*, const QPoint &, int)), this, SLOT(down(QListViewItem*, const QPoint &, int)) );
}

void QFileView::resizeEvent(QResizeEvent* re)
{
  lv->move(0, bup->height() );
  lv->resize(re->size().width(), re->size().height() - bup->height() );
}

void QFileView::populate()
{
  fi.open();
  while( fi.nextFile())
  {
    if ( !fi.isHidden() )
      new QListViewItem( lv, fi.getName().c_str(), fi.getOwner().c_str(), fi.getGroup().c_str(), fi.getPermissions().c_str() );
  }
  fi.close();
}

void QFileView::up()
{
  fi.up();
  lv->clear();
  populate();
}

void QFileView::down(QListViewItem* lvi, const QPoint& p, int col)
{
  if(fi.isDir(lvi->text(0)))
  {
    fi.down(lvi->text(0));
    lv->clear();
    populate();
  }
}
 
Old 12-09-2007, 02:12 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
With a seg fault the easiest way to work out what is going on is to use a debugger and generate a stack trace. If you use KDevelop then GDB is integrated into it and you can quickly see where the problem is.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is a segmentation fault? 144419855310001 Fedora 1 04-28-2006 08:39 AM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika Suse/Novell 2 12-02-2005 10:34 AM
Help !!! Segmentation fault mola Linux - Software 3 06-23-2005 12:13 PM
Segmentation fault tejas15_10 Programming 9 06-20-2005 10:12 AM
Segmentation fault tejas15_10 Linux - Newbie 1 06-14-2005 05:44 AM


All times are GMT -5. The time now is 06:12 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration