96
96
int s_nCrtStepSize;
101
HANDLE s_hStepFile (INVALID_HANDLE_VALUE);
102
void traceToFile(const string& s)
107
void traceToFile(const string& s, int nLevelChange)
104
109
if (!s_bEnableTraceToFile) { return; }
106
111
static QMutex mutex;
107
112
QMutexLocker lck (&mutex);
114
static int s_nLevel (0);
115
s_nLevel += nLevelChange;
116
string s1 (s_nLevel, ' ');
109
119
QTime t (QTime::currentTime());
111
sprintf(a, "%02d:%02d:%02d.%03d ", t.hour(), t.minute(), t.second(), t.msec());
121
sprintf(a, "%02d:%02d:%02d.%03d", t.hour(), t.minute(), t.second(), t.msec());
113
123
ofstream_utf8 out (s_strTraceFile.c_str(), ios_base::app);
114
out << a << s << endl;
118
void traceLastStep(const string& s)
124
out << a << s1 << endl;
131
void CB_LIB_CALL displayOsErrorIfExists(const char* szTitle)
133
unsigned int nErr (GetLastError());
134
if (0 == nErr) return;
139
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
142
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
148
string strRes ((LPSTR)lpMsgBuf);
152
unsigned int nSize ((unsigned int)strRes.size());
153
if (nSize - 2 == strRes.rfind("\r\n"))
155
strRes.resize(nSize - 2);
158
QMessageBox::critical(0, szTitle, convStr(strRes));
167
void traceLastStep(const string& s, int nLevelChange)
120
169
if (!s_bEnableTraceToFile) { return; }
122
171
static QMutex mutex;
123
172
QMutexLocker lck (&mutex);
125
QTime t (QTime::currentTime());
174
static int s_nLevel (0);
175
s_nLevel += nLevelChange;
176
string s1 (s_nLevel, ' ');
177
//string s1; char b [20]; sprintf(b, "%d", s_nLevel); s1 = b;
128
//sprintf(a, "%02d:%02d:%02d.%03d ", t.hour(), t.minute(), t.second(), t.msec());
182
//QTime t (QTime::currentTime()); sprintf(a, "%02d:%02d:%02d.%03d ", t.hour(), t.minute(), t.second(), t.msec());
130
185
ofstream_utf8 out (s_vstrStepFile[s_nStepFile].c_str(), ios_base::app);
131
out << a << s << endl;
186
out << a << s1 << endl;
188
/*FILE* f (fopen(s_vstrStepFile[s_nStepFile].c_str(), "a+"));
189
fwrite(a, strlen(a), 1, f);
190
fwrite(s.c_str(), s.size(), 1, f);
191
fwrite("\n", 1, 1, f);
195
//HANDLE h (CreateFileA(toNativeSeparators(s_vstrStepFile[s_nStepFile]).c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS,
196
HANDLE h (CreateFileA(s_vstrStepFile[s_nStepFile].c_str(), GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, OPEN_ALWAYS,
197
//HANDLE h (CreateFileA("C:\\Mp3DiagsWindows\\debug\\aaa.txt", GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS,
198
//HANDLE h (CreateFileA("C:\\Mp3DiagsWindows\\debug\\aaa.txt", GENERIC_WRITE, 0, 0, OPEN_ALWAYS,
199
FILE_ATTRIBUTE_TEMPORARY,
200
//FILE_ATTRIBUTE_NORMAL,
202
if (INVALID_HANDLE_VALUE == h)
204
displayOsErrorIfExists();
207
SetFilePointer(h, 0, 0, FILE_END);
209
WriteFile(h, a, strlen(a), &dwWrt, 0);
210
WriteFile(h, s.c_str(), s.size(), &dwWrt, 0);
211
WriteFile(h, "\n", 1, &dwWrt, 0);
212
//const char* qq ("abcdefg");
213
//QMessageBox::critical(0, "abc", "before wrt");
214
//WriteFile(h, qq, 4, 0, 0);
215
//QMessageBox::critical(0, "123", "after wrt");
133
220
s_nCrtStepSize += s.size() + 1;
221
if (s_nCrtStepSize > 5000000)
224
s_nStepFile = 1 - s_nStepFile;
227
deleteFile(s_vstrStepFile[s_nStepFile]);
232
//ofstream_utf8 out (s_vstrStepFile[s_nStepFile].c_str(), ios_base::app);
233
//out << "page " << s_nPage++ << endl;
237
//HANDLE h (CreateFileA("C:\\Mp3DiagsWindows\\debug\\aaa.txt", GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS,
238
//HANDLE h (CreateFileA("C:\\Mp3DiagsWindows\\debug\\aaa.txt", GENERIC_WRITE, 0, 0, OPEN_ALWAYS,
239
/*static HANDLE h (CreateFileA(s_vstrStepFile[s_nStepFile].c_str(),
241
FILE_SHARE_WRITE | FILE_SHARE_READ,
245
FILE_ATTRIBUTE_TEMPORARY,
246
//FILE_ATTRIBUTE_NORMAL,
250
WriteFile(s_hStepFile, a, strlen(a), &dwWrt, 0);
251
WriteFile(s_hStepFile, s1.c_str(), s1.size(), &dwWrt, 0);
252
WriteFile(s_hStepFile, "\r\n", 2, &dwWrt, 0);
255
s_nCrtStepSize += s1.size() +
134
262
if (s_nCrtStepSize > 50000)
136
264
s_nCrtStepSize = 0;
682
851
if (fileExists(s_strTraceFile))
684
showErrorDlg2(this, "Restarting after crash", "MP3 Diags is restarting after a crash. Information in the files \"" + Qt::escape(toNativeSeparators(convStr(s_strTraceFile))) + "\", \"" + Qt::escape(toNativeSeparators(convStr(s_vstrStepFile[0]))) + "\", and \"" + Qt::escape(toNativeSeparators(convStr(s_vstrStepFile[1]))) + "\" may help identify the cause of the crash, so please make them available to the developer by mailing them to <a href=\"mailto:ciobi@inbox.com?subject=000 MP3 Diags crash/\">ciobi@inbox.com</a>, by reporting an issue to the project's <a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">MP3 Diags Issue Tracker</a> (<a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">http://sourceforge.net/apps/mantisbt/mp3diags/</a>) and attaching the files to the report, or by some other means (like putting them on a web server.)<p/><p/>These are plain text files, which you can review before sending, if you have privacy concerns.<p/><p/>After getting the files, the developer will probably want to contact you for more details, so please check back on the status of your report.<p/><p/>So please send these files, as well as any other detail that seems relevant (what might have caused the failure, steps to reproduce it, ...)<p/><p/><hr/><p/>", "OK");
853
showErrorDlg2(this, "Restarting after crash", "<p style=\"margin-bottom:8px; margin-top:1px; \">MP3 Diags is restarting after a crash. Information in the files \"" + Qt::escape(toNativeSeparators(convStr(s_strTraceFile))) + "\", \"" + Qt::escape(toNativeSeparators(convStr(s_vstrStepFile[0]))) + "\", and \"" + Qt::escape(toNativeSeparators(convStr(s_vstrStepFile[1]))) + "\" may help identify the cause of the crash, so please make them available to the developer by mailing them to <a href=\"mailto:ciobi@inbox.com?subject=000 MP3 Diags crash/\">ciobi@inbox.com</a>, by reporting an issue to the project's <a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">Issue Tracker</a> (<a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">http://sourceforge.net/apps/mantisbt/mp3diags/</a>) and attaching the files to the report, or by some other means (like putting them on a web server.)</p><p style=\"margin-bottom:8px; margin-top:1px; \">These are plain text files, which you can review before sending, if you have privacy concerns.</p><p style=\"margin-bottom:8px; margin-top:1px; \">After getting the files, the developer will probably want to contact you for more details, so please check back on the status of your report.</p><p style=\"margin-bottom:8px; margin-top:1px; \">So please send these files, as well as any other detail that seems relevant (what might have caused the failure, steps to reproduce it, ...)</p>", "Remove these files and continue");
685
854
//ttt0 perhaps loop until the file is deleted
689
showErrorDlg2(this, "Restarting after crash", "MP3 Diags is restarting after a crash. There was supposed to be some information about what led to the crash in the file \"" + Qt::escape(toNativeSeparators(convStr(s_strTraceFile))) + "\", but that file cannot be found. Please report this issue to the project's <a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">MP3 Diags Issue Tracker</a> (<a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">http://sourceforge.net/apps/mantisbt/mp3diags/</a>)<p/><p/>The developer will probably want to contact you for more details, so please check back on the status of your report.<p/>Make sure to include the data below, as well as any other detail that seems relevant (what might have caused the failure, steps to reproduce it, ...)<p/><p/><hr/><p/>", "OK");
858
showErrorDlg2(this, "Restarting after crash", "<p style=\"margin-bottom:8px; margin-top:1px; \">MP3 Diags is restarting after a crash. There was supposed to be some information about what led to the crash in the file \"" + Qt::escape(toNativeSeparators(convStr(s_strTraceFile))) + "\", but that file cannot be found. Please report this issue to the project's <a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">Issue Tracker</a> (<a href=\"http://sourceforge.net/apps/mantisbt/mp3diags/\">http://sourceforge.net/apps/mantisbt/mp3diags/</a>)</p><p style=\"margin-bottom:8px; margin-top:1px; \">The developer will probably want to contact you for more details, so please check back on the status of your report.</p><p style=\"margin-bottom:8px; margin-top:1px; \">Make sure to include the data below, as well as any other detail that seems relevant (what might have caused the failure, steps to reproduce it, ...)</p>", "OK");