Results 1 to 6 of 6

Thread: Loading text with the first line ending with tabulator causes crash

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: Loading text with the first line ending with tabulator causes crash

    I tried to make a small example containing the critical code, but it is not exact the same, since the program already crashes loading the file.

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QtGui/QMainWindow>
    5. #include <QtGui>
    6.  
    7. class MainWindow : public QMainWindow
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. MainWindow(QWidget *parent = 0);
    13. ~MainWindow();
    14.  
    15. private:
    16. QLabel *label;
    17. };
    18.  
    19. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. MainWindow::MainWindow(QWidget *parent)
    4. : QMainWindow(parent)
    5. {
    6. this->label = new QLabel();
    7. this->setCentralWidget(label);
    8.  
    9.  
    10. QString filePath("crash.txt");
    11. QFile f(filePath);
    12. if(f.open(QFile::ReadOnly)) {
    13. QTextStream s(&f);
    14.  
    15. this->label->setText(s.readAll()); // Crash
    16. } else {
    17. this->label->setText(tr("File ") + filePath + tr(" could not be read."));
    18. }
    19. }
    20.  
    21. MainWindow::~MainWindow()
    22. {
    23.  
    24. }
    To copy to clipboard, switch view to plain text mode 

    Just calling s.readAll() works fine.
    I attached the file that causes the crash. Again everything works, if i delete the tab.
    Attached Files Attached Files

Similar Threads

  1. loadFromData() of QImage crash in case of .gif loading
    By santosh.kumar in forum Qt Programming
    Replies: 11
    Last Post: 9th March 2011, 11:52
  2. loadFromData() of QImage -crash in case of .gif loading
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2011, 11:56
  3. QPlainText Edit and text lines
    By aarelovich in forum Qt Programming
    Replies: 4
    Last Post: 23rd June 2010, 13:09
  4. plot with hor. lines and text
    By hugo vanwoerkom in forum Qwt
    Replies: 2
    Last Post: 10th March 2010, 17:00
  5. I want to get lines of text
    By newplayer in forum Qt Programming
    Replies: 11
    Last Post: 29th July 2008, 09:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.