Skip to content

Commit

Permalink
Windows patches
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Jan 31, 2010
1 parent 726f819 commit e949243
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 170 deletions.
4 changes: 2 additions & 2 deletions src/backup.cpp
Expand Up @@ -233,7 +233,7 @@ void BackupDialog::backup()
while (thread.isRunning()) {
progress->setValue(progress->value() + 1); // Or else, the animation is not played!
kapp->processEvents();
usleep(300); // Not too long because if the backup process is finished, we wait for nothing
// usleep(300); // Not too long because if the backup process is finished, we wait for nothing
}

Settings::setLastBackup(QDate::currentDate());
Expand Down Expand Up @@ -292,7 +292,7 @@ void BackupDialog::restore()
while (thread.isRunning()) {
progress->setValue(progress->value() + 1); // Or else, the animation is not played!
kapp->processEvents();
usleep(300); // Not too long because if the restore process is finished, we wait for nothing
// usleep(300); // Not too long because if the restore process is finished, we wait for nothing
}

dialog->hide(); // The restore is finished, do not continue to show it while telling the user the application is going to be restarted
Expand Down
2 changes: 1 addition & 1 deletion src/basketview.cpp
Expand Up @@ -5216,7 +5216,7 @@ bool BasketView::saveToFile(const QString& fullPath, const QByteArray& array, un
static const uint sleepDelay = 50; // ms
for (uint i = 0; i < retryDelay / sleepDelay; ++i) {
kapp->processEvents();
usleep(sleepDelay * 1000); // usec
// usleep(sleepDelay * 1000); // usec
}
// Double the retry delay, but don't go over the max.
retryDelay = qMin(maxDelay, retryDelay * 2); // ms
Expand Down
2 changes: 1 addition & 1 deletion src/bnpview.cpp
Expand Up @@ -1954,7 +1954,7 @@ void BNPView::grabScreenshot(bool global)
m_colorPickWasShown = false;

currentBasket()->saveInsertionData();
usleep(delay * 1000);
//usleep(delay * 1000);
m_regionGrabber = new RegionGrabber;
connect(m_regionGrabber, SIGNAL(regionGrabbed(const QPixmap&)), this, SLOT(screenshotGrabbed(const QPixmap&)));
}
Expand Down
330 changes: 165 additions & 165 deletions src/crashhandler.cpp
Expand Up @@ -30,7 +30,7 @@
#include <cstdio> //popen, fread
#include <iostream>
#include <sys/types.h> //pid_t
#include <sys/wait.h> //waitpid
// #include <sys/wait.h> //waitpid
//#include <taglib/taglib.h>
#include <unistd.h> //write, getpid
#include <ktoolinvocation.h>
Expand All @@ -54,173 +54,173 @@ class CrashHandlerWidget : public KDialog
static QString
runCommand(const QByteArray &command)
{
static const uint SIZE = 40960; //40 KiB
static char stdoutBuf[ SIZE ];

// debug() << "Running: " << command << endl;

FILE *process = ::popen(command, "r");
stdoutBuf[ std::fread(static_cast<void*>(stdoutBuf), sizeof(char), SIZE-1, process)] = '\0';
::pclose(process);

return QString::fromLocal8Bit(stdoutBuf);
// static const uint SIZE = 40960; //40 KiB
// static char stdoutBuf[ SIZE ];
//
// // debug() << "Running: " << command << endl;
//
// FILE *process = ::popen(command, "r");
// stdoutBuf[ std::fread(static_cast<void*>(stdoutBuf), sizeof(char), SIZE-1, process)] = '\0';
// ::pclose(process);

return "Not supported";
}

void
Crash::crashHandler(int /*signal*/)
{
// we need to fork to be able to get a
// semi-decent bt - I dunno why
const pid_t pid = ::fork();

if (pid <= 0) {
// we are the child process (the result of the fork)
// debug() << "amaroK is crashing...\n";

QString subject = "[basket-crash] " VERSION " ";
QString body = i18n(
"%1 has crashed! We're sorry about this.\n"
"\n"
"But, all is not lost! You could potentially help us fix the crash. "
"Information describing the crash is below, so just click send, "
"or if you have time, write a brief description of how the crash happened first.\n\n"
"Many thanks.", KGlobal::mainComponent().aboutData()->programName()) + "\n\n";
body += "\n\n\n\n\n\n" + i18n(
"The information below is to help the developers identify the problem, "
"please do not modify it.") + "\n\n\n\n";


body += "======== DEBUG INFORMATION =======\n"
"Version: " VERSION "\n"
"Build date: " __DATE__ "\n"
"CC version: " __VERSION__ "\n" //assuming we're using GCC
"KDElibs: " KDE_VERSION_STRING "\n"
;// "TagLib: %2.%3.%4\n";

/* body = body
.arg( TAGLIB_MAJOR_VERSION )
.arg( TAGLIB_MINOR_VERSION )
.arg( TAGLIB_PATCH_VERSION );*/

#ifdef NDEBUG
body += "NDEBUG: true";
#endif
body += "\n";

/// obtain the backtrace with gdb

KTemporaryFile temp;
temp.setAutoRemove(true);

const int handle = temp.handle();

// QCString gdb_command_string =
// "file amarokapp\n"
// "attach " + QCString().setNum( ::getppid() ) + "\n"
// "bt\n" "echo \\n\n"
// "thread apply all bt\n";

const QByteArray gdb_batch =
"bt\n"
"echo \\n\\n\n"
"bt full\n"
"echo \\n\\n\n"
"echo ==== (gdb) thread apply all bt ====\\n\n"
"thread apply all bt\n";

::write(handle, gdb_batch, gdb_batch.length());
::fsync(handle);

// so we can read stderr too
::dup2(fileno(stdout), fileno(stderr));


QByteArray gdb;
gdb = "gdb --nw -n --batch -x ";
gdb += temp.fileName().toLatin1();
gdb += " basket ";
gdb += QByteArray().setNum(::getppid());

QString bt = runCommand(gdb);

/// clean up
bt.remove("(no debugging symbols found)...");
bt.remove("(no debugging symbols found)\n");
bt.replace(QRegExp("\n{2,}"), "\n"); //clean up multiple \n characters
bt.trimmed();

/// analyze usefulness
bool useful = true;
const QString fileCommandOutput = runCommand("file `which basket`");

if (fileCommandOutput.indexOf("not stripped") == -1)
subject += "[___stripped]"; //same length as below
else
subject += "[NOTstripped]";

if (!bt.isEmpty()) {
const int invalidFrames = bt.count(QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in \\?\\?"));
const int validFrames = bt.count(QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in [^?]"));
const int totalFrames = invalidFrames + validFrames;

if (totalFrames > 0) {
const double validity = double(validFrames) / totalFrames;
subject += QString("[validity: %1]").arg(validity, 0, 'f', 2);
if (validity <= 0.5) useful = false;
}
subject += QString("[frames: %1]").arg(totalFrames, 3 /*padding*/);

if (bt.indexOf(QRegExp(" at \\w*\\.cpp:\\d+\n")) != -1)
subject += "[line numbers]";
} else
useful = false;

// subject += QString("[%1]").arg( AmarokConfig::soundSystem().remove( QRegExp("-?engine") ) );

// debug() << subject << endl;


//TODO -fomit-frame-pointer buggers up the backtrace, so detect it
//TODO -O optimization can rearrange execution and stuff so show a warning for the developer
//TODO pass the CXXFLAGS used with the email

if (useful) {
body += "==== file `which basket` ==========\n";
body += fileCommandOutput + "\n";
body += "==== (gdb) bt =====================\n";
body += bt;//+ "\n\n";
// body += "==== kBacktrace() ================\n";
// body += kBacktrace();

//TODO startup notification
KToolInvocation::invokeMailer(
/*to*/ "kelvie@ieee.org",
/*cc*/ QString(),
/*bcc*/ QString(),
/*subject*/ subject,
/*body*/ body,
/*messageFile*/ QString(),
/*attachURLs*/ QStringList(),
/*startup_id*/ "");
} else {
kDebug() << "\n" + i18n("%1 has crashed! We're sorry about this.\n\n"
"But, all is not lost! Perhaps an upgrade is already available "
"which fixes the problem. Please check your distribution's software repository.",
KGlobal::mainComponent().aboutData()->programName());
}

//_exit() exits immediately, otherwise this
//function is called repeatedly ad finitum
::_exit(255);
}

else {
// we are the process that crashed

::alarm(0);

// wait for child to exit
::waitpid(pid, NULL, 0);
::_exit(253);
}
// // we need to fork to be able to get a
// // semi-decent bt - I dunno why
// const pid_t pid = ::fork();
//
// if (pid <= 0) {
// // we are the child process (the result of the fork)
// // debug() << "amaroK is crashing...\n";
//
// QString subject = "[basket-crash] " VERSION " ";
// QString body = i18n(
// "%1 has crashed! We're sorry about this.\n"
// "\n"
// "But, all is not lost! You could potentially help us fix the crash. "
// "Information describing the crash is below, so just click send, "
// "or if you have time, write a brief description of how the crash happened first.\n\n"
// "Many thanks.", KGlobal::mainComponent().aboutData()->programName()) + "\n\n";
// body += "\n\n\n\n\n\n" + i18n(
// "The information below is to help the developers identify the problem, "
// "please do not modify it.") + "\n\n\n\n";
//
//
// body += "======== DEBUG INFORMATION =======\n"
// "Version: " VERSION "\n"
// "Build date: " __DATE__ "\n"
// "CC version: " __VERSION__ "\n" //assuming we're using GCC
// "KDElibs: " KDE_VERSION_STRING "\n"
// ;// "TagLib: %2.%3.%4\n";
//
// /* body = body
// .arg( TAGLIB_MAJOR_VERSION )
// .arg( TAGLIB_MINOR_VERSION )
// .arg( TAGLIB_PATCH_VERSION );*/
//
// #ifdef NDEBUG
// body += "NDEBUG: true";
// #endif
// body += "\n";
//
// /// obtain the backtrace with gdb
//
// KTemporaryFile temp;
// temp.setAutoRemove(true);
//
// const int handle = temp.handle();
//
// // QCString gdb_command_string =
// // "file amarokapp\n"
// // "attach " + QCString().setNum( ::getppid() ) + "\n"
// // "bt\n" "echo \\n\n"
// // "thread apply all bt\n";
//
// const QByteArray gdb_batch =
// "bt\n"
// "echo \\n\\n\n"
// "bt full\n"
// "echo \\n\\n\n"
// "echo ==== (gdb) thread apply all bt ====\\n\n"
// "thread apply all bt\n";
//
// ::write(handle, gdb_batch, gdb_batch.length());
// ::fsync(handle);
//
// // so we can read stderr too
// ::dup2(fileno(stdout), fileno(stderr));
//
//
// QByteArray gdb;
// gdb = "gdb --nw -n --batch -x ";
// gdb += temp.fileName().toLatin1();
// gdb += " basket ";
// gdb += QByteArray().setNum(::getppid());
//
// QString bt = runCommand(gdb);
//
// /// clean up
// bt.remove("(no debugging symbols found)...");
// bt.remove("(no debugging symbols found)\n");
// bt.replace(QRegExp("\n{2,}"), "\n"); //clean up multiple \n characters
// bt.trimmed();
//
// /// analyze usefulness
// bool useful = true;
// const QString fileCommandOutput = runCommand("file `which basket`");
//
// if (fileCommandOutput.indexOf("not stripped") == -1)
// subject += "[___stripped]"; //same length as below
// else
// subject += "[NOTstripped]";
//
// if (!bt.isEmpty()) {
// const int invalidFrames = bt.count(QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in \\?\\?"));
// const int validFrames = bt.count(QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in [^?]"));
// const int totalFrames = invalidFrames + validFrames;
//
// if (totalFrames > 0) {
// const double validity = double(validFrames) / totalFrames;
// subject += QString("[validity: %1]").arg(validity, 0, 'f', 2);
// if (validity <= 0.5) useful = false;
// }
// subject += QString("[frames: %1]").arg(totalFrames, 3 /*padding*/);
//
// if (bt.indexOf(QRegExp(" at \\w*\\.cpp:\\d+\n")) != -1)
// subject += "[line numbers]";
// } else
// useful = false;
//
// // subject += QString("[%1]").arg( AmarokConfig::soundSystem().remove( QRegExp("-?engine") ) );
//
// // debug() << subject << endl;
//
//
// //TODO -fomit-frame-pointer buggers up the backtrace, so detect it
// //TODO -O optimization can rearrange execution and stuff so show a warning for the developer
// //TODO pass the CXXFLAGS used with the email
//
// if (useful) {
// body += "==== file `which basket` ==========\n";
// body += fileCommandOutput + "\n";
// body += "==== (gdb) bt =====================\n";
// body += bt;//+ "\n\n";
// // body += "==== kBacktrace() ================\n";
// // body += kBacktrace();
//
// //TODO startup notification
// KToolInvocation::invokeMailer(
// /*to*/ "kelvie@ieee.org",
// /*cc*/ QString(),
// /*bcc*/ QString(),
// /*subject*/ subject,
// /*body*/ body,
// /*messageFile*/ QString(),
// /*attachURLs*/ QStringList(),
// /*startup_id*/ "");
// } else {
// kDebug() << "\n" + i18n("%1 has crashed! We're sorry about this.\n\n"
// "But, all is not lost! Perhaps an upgrade is already available "
// "which fixes the problem. Please check your distribution's software repository.",
// KGlobal::mainComponent().aboutData()->programName());
// }
//
// //_exit() exits immediately, otherwise this
// //function is called repeatedly ad finitum
// ::_exit(255);
// }
//
// else {
// // we are the process that crashed
//
// ::alarm(0);
//
// // wait for child to exit
// ::waitpid(pid, NULL, 0);
// ::_exit(253);
// }
}
2 changes: 1 addition & 1 deletion src/likeback.cpp
Expand Up @@ -48,7 +48,7 @@
#include <QValidator>
#include <QAction>

#include <pwd.h>
// #include <pwd.h>

#include <KDE/KGlobal>

Expand Down
1 change: 1 addition & 0 deletions src/notedrag.h
Expand Up @@ -82,6 +82,7 @@ class ExtendedTextDrag : public QDrag
{
Q_OBJECT
public:
ExtendedTextDrag(QWidget * source);
static bool decode(const QMimeData *e, QString &str);
static bool decode(const QMimeData *e, QString &str, QString &subtype);
};
Expand Down

0 comments on commit e949243

Please sign in to comment.