Results 1 to 4 of 4

Thread: Weird RtlWerpReportException error

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Weird RtlWerpReportException error

    Hello!

    I'm was revising the code of a old software and changing it's scope a little (note: the old version compiled and run perfectly), when I tried to compile and run it and it returned a bizzare error:

    Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly
    I didn't find much about RtlWerpReportException on the web, much less as in my particular situation, so I hope you guys could say what is wrong with my App.

    Here is old code and the new code for comparison. As you can see, while there are some significant differences between them, there is no 'special' code that would suggest any kind of error; there is only basic Gui functions and QDir/QFile usage.


    Qt Code:
    1. //Old main.cpp:
    2.  
    3. #include <QtGui/QApplication>
    4. #include "mainwindow.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9. app.setApplicationName("mNote");
    10. app.setApplicationVersion(QString::number(VERSION));
    11. app.setOrganizationName("Martin");
    12.  
    13. MainWindow window;
    14.  
    15. window.show();
    16.  
    17. return app.exec();
    18. }
    19.  
    20. //New main.cpp:
    21.  
    22. #include <QtGui/QApplication>
    23. #include "mainwindow.h"
    24.  
    25. int main(int argc, char *argv[])
    26. {
    27. QApplication app(argc, argv);
    28. app.setApplicationName("mNote");
    29. app.setApplicationVersion(QString::number(VERSION));
    30. app.setOrganizationName("Martinware");
    31. app.setOrganizationDomain("http://www.martinware.com");
    32.  
    33. MainWindow window;
    34.  
    35. return app.exec();
    36. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //Old mainwindow.cpp:
    2.  
    3. #include "mainwindow.h"
    4. #include "ui_mainwindow.h"
    5.  
    6. MainWindow::MainWindow(QWidget *parent) :
    7. QMainWindow(parent),
    8. ui(new Ui::MainWindow)
    9. {
    10. ui->setupUi(this);
    11.  
    12. //---------------------------- THIS
    13. setWindowIcon(QIcon(":/Images/Images/Sticky_Note.png"));
    14. setWindowTitle("mNote");
    15. setMinimumSize(350,350);
    16.  
    17. //---------------------------- SETA FLAGS
    18. psrandomalarm = 0; howmuchloops = 0;
    19. Flags.caseChange = false, Flags.entrounominuto = false, Flags.ja_aberto_nesse_dia = false, Flags.leitura_inicial_ocorrendo = false;
    20.  
    21. //---------------------------- FORM/UI
    22. ui->mainToolBar->setMovable(false);
    23. ui->statusBar->hide();
    24. ui->actionDelete_note->setDisabled(true);
    25. ui->actionDo_this_later->setDisabled(true);
    26. ui->actionOpen_historic->setDisabled(true);
    27.  
    28. ui->TabWidget->setTabText(0,"Specific");
    29. ui->TabWidget->setTabText(1,"Daily");
    30. ui->TabWidget->setTabText(2,"Memory");
    31. ui->TabWidget->setCurrentIndex(TAB_DAILY);
    32.  
    33. // Configure action buttons
    34. ui->actionNew_note->setShortcut(Qt::ControlModifier + Qt::Key_N);
    35. ui->actionDelete_note->setShortcut(Qt::ControlModifier + Qt::Key_D);
    36. ui->actionHide->setShortcut(Qt::ControlModifier + Qt::Key_H);
    37. ui->actionDo_this_later->setShortcut(Qt::ControlModifier + Qt::Key_L);
    38.  
    39. //--------------------------- DEFINE SOURCES DAS NOTAS SALVAS
    40.  
    41. // Cria diretorio onde as notas ficarão salvas
    42. QDir txtdirectory;
    43. QString v_txtdirectoryname = "./mNote";
    44.  
    45. if (!txtdirectory.exists(v_txtdirectoryname))
    46. txtdirectory.mkpath(v_txtdirectoryname);
    47.  
    48.  
    49. filename_daily = "./mNote/Daily.txt"; //Notas de todos os dias
    50. filename_time = "./mNote/Time.txt"; //Salva quando foi a última vez que o software foi aberto (usado com o Daily)
    51.  
    52. // Para poder fazer a leitura dos arquivos, é necessário que existam. Se eles não existirem,
    53. // mandar ler vai dar bug; por isso, verifica-se primeiramente se o texto exste.
    54. // Se não existe, se cria um escrevendo vazio ("") nele.
    55.  
    56. // Define texto 1
    57. {
    58. MReadWrite *mrw = new MReadWrite(this);
    59.  
    60. if (!mrw->exists(filename_daily))
    61. {
    62. if (!mrw->createFile(filename_daily))
    63. {
    64. QMessageBox::warning(this,"Problem creating Daily text file","A problem occured while trying to create a text file for data storage.\nPlease, go to the folder \"mNote\" and "
    65. "create the text file \"Daily.text\".");
    66. close();
    67. }
    68. }
    69.  
    70. SAFEDELETE(mrw);
    71. }
    72.  
    73. //New mainwindow.cpp:
    74. #include "mainwindow.h"
    75. #include "ui_mainwindow.h"
    76.  
    77. const QString filenameNotes = QDir::currentPath() + "/mNote/Notes.txt"; //Notas
    78.  
    79. const QString noteSeparator = ";_;";
    80. const QString itemSeparator = ";;";
    81.  
    82.  
    83. MainWindow::MainWindow(QWidget *parent) :
    84. QMainWindow(parent),
    85. ui(new Ui::MainWindow)
    86. {
    87. ui->setupUi(this);
    88.  
    89. //---------------------------- THIS
    90. setWindowIcon(QIcon(":/Images/Images/Sticky_Note.png"));
    91. setWindowTitle("mNote");
    92. setMinimumSize(350,350);
    93.  
    94. //---------------------------- SETA FLAGS
    95. psRandomAlarm = 0; howMuchLoops = 0;
    96. Flags.entrounominuto =
    97. Flags.ja_aberto_nesse_dia =
    98. Flags.leitura_inicial_ocorrendo = false;
    99.  
    100. //---------------------------- FORM/UI
    101. ui->mainToolBar->setMovable(false);
    102. ui->statusBar->hide();
    103. ui->actionDelete_note->setDisabled(true);
    104. ui->actionDo_this_later->setDisabled(true);
    105. ui->actionOpen_historic->setDisabled(true);
    106.  
    107. ui->TabWidget->setTabText(0,"Today");
    108. ui->TabWidget->setTabText(1,"Weekly");
    109. ui->TabWidget->setTabText(2,"For Tomorrow");
    110. ui->TabWidget->setCurrentIndex(TAB_WEAKLY);
    111.  
    112. // Configure action buttons
    113. ui->actionNew_note->setShortcut(Qt::ControlModifier + Qt::Key_N);
    114. ui->actionDelete_note->setShortcut(Qt::ControlModifier + Qt::Key_D);
    115. ui->actionHide->setShortcut(Qt::ControlModifier + Qt::Key_H);
    116. ui->actionDo_this_later->setShortcut(Qt::ControlModifier + Qt::Key_L);
    117.  
    118. //--------------------------- DEFINE SOURCES DAS NOTAS SALVAS
    119.  
    120. // Cria diretorio onde as notas ficarão salvas
    121. QDir txtdirectory;
    122. const QString v_txtdirectoryname = "./mNote";
    123.  
    124. if (!txtdirectory.exists(v_txtdirectoryname))
    125. txtdirectory.mkpath(v_txtdirectoryname);
    126.  
    127. // Para poder fazer a leitura dos arquivos, é necessário que existam. Se eles não existirem,
    128. // mandar ler vai dar bug; por isso, verifica-se primeiramente se o texto exste.
    129. // Se não existe, se cria um escrevendo vazio ("") nele.
    130.  
    131. // Define texto 1
    132. {
    133. QDir dirt;
    134. dirt.setPath(QDir::currentPath() + "/mNote");
    135.  
    136. if (!dirt.exists() && !dirt.mkdir(dirt.path()))
    137. {
    138. QMessageBox::warning(this,"Error","Failure creating folder \"mNote\", required for the correct usage of this software.\n"
    139. "Go to the installation folder and add this folder so mNote may be used.");
    140. close();
    141. }
    142.  
    143. MReadWrite *mrw = new MReadWrite(this);
    144.  
    145. if (!mrw->exists(filenameNotes) && !mrw->createFile(filenameNotes))
    146. {
    147. QMessageBox::warning(this,"Problem creating text file","A problem occured while trying to create a text file for data storage.\nPlease, go to the folder \"mNote\" and "
    148. "create the text file \"Notes.txt\".");
    149. SAFEDELETE(mrw);
    150. close();
    151. }
    152.  
    153. SAFEDELETE(mrw);
    154. }
    To copy to clipboard, switch view to plain text mode 

    Note: MReadWrite is a class for writing to and reading from files. No problem ever shown.

    Actually the mainwindow.cpp is bigger than what I'm showing, but it's not necessary to post more, I believe, because I found that the error occurs when the code goes to the SAFEDELETE() function above. The SAFEDELETE() function is a define:

    Qt Code:
    1. #define SAFEDELETE(_P) if(_P) {delete _P; _P = NULL;}
    To copy to clipboard, switch view to plain text mode 

    This function never returned any problems, and as you can see, it was already being used in the old mainwindow.cpp code without errors. MReadWrite could also be the faulty guy, but it's version is the same as the MReadWrite used in the old version and once again there was no errors back then.


    I'm glad for any help you could give!!

    Momergil


    Added after 12 minutes:


    Ok, It seems I found the problem: actually MReadWrite did suffer some modifications and I didn't remember. Particulary I added a destructor function that deletes a global QTextStream pointer that in my mNote application wasn't declared yet. So when I commented the "delete qts;", the software could run properly.

    The problem now is a new one: in order to avoid that, I added my SAFEDELETE function in the MReadWrite.cpp so it would delete the QTextStream pointer only if it got declared. But instead of doing so, it began to report the same error talked about above. I have no guess why SAFEDELETE() wouldn't work, making my app crash; after all, it verifies if the _P is declared and only then it deletes it.
    Last edited by Momergil; 12th July 2013 at 15:23.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Weird RtlWerpReportException error

    You are ensuring that the global QTextStream pointer is initialised to zero at program start aren't you.

  3. The following user says thank you to ChrisW67 for this useful post:

    Momergil (11th August 2013)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Weird RtlWerpReportException error

    Quote Originally Posted by ChrisW67 View Post
    You are ensuring that the global QTextStream pointer is initialised to zero at program start aren't you.
    you mean,

    Qt Code:
    1. //.h
    2. QTextStream *globalPointer;
    3.  
    4. //.cpp
    5. constructor
    6. {
    7. globalPointer = NULL;
    8. }
    To copy to clipboard, switch view to plain text mode 

    ?

    Nops. The pointer is only declared when a openRead or openWrite function is called. Is this required for my SAFEDELETE() to work properly?
    Last edited by Momergil; 14th July 2013 at 17:06.

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Weird RtlWerpReportException error

    I am referring to this:
    Ok, It seems I found the problem: actually MReadWrite did suffer some modifications and I didn't remember. Particulary I added a destructor function that deletes a global QTextStream pointer that in my mNote application wasn't declared yet.
    If you never initialised the global pointer to zero, never assign to the variable, and then used your macro on it then your program would crash more often than not: you would try to delete some random memory that was never allocated to you. Variables are not initialised by magic.

    In your code it makes no sense to create your MReadWrite object on the heap, use, and discard it immediately. You could just put it on the stack and not have to worry about tracking memory at all.

Similar Threads

  1. QStyledItemDelegate Weird Error
    By daleotar in forum Qt Programming
    Replies: 4
    Last Post: 19th July 2011, 20:56
  2. QSqlQuery.exec() weird error
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2010, 13:02
  3. Weird QTextEdit error
    By MarkoSan in forum Qt Programming
    Replies: 8
    Last Post: 31st March 2008, 10:05
  4. Weird compile error
    By MarkoSan in forum Qt Programming
    Replies: 6
    Last Post: 3rd December 2007, 18:50
  5. weird error
    By mickey in forum General Programming
    Replies: 6
    Last Post: 18th November 2006, 04:22

Tags for this Thread

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.