LinuxQuestions.org
Visit Jeremy's Blog.
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
 
LinkBack Search this Thread
Old 12-08-2007, 08:31 PM   #1
binarybob0001
Member
 
Registered: Dec 2004
Distribution: Debian Wheezy
Posts: 433

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, 01:12 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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


All times are GMT -5. The time now is 05:30 AM.

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