Merge branch 'master' into otio

This commit is contained in:
itsmattkc
2020-09-23 12:27:45 +10:00
63 changed files with 1649 additions and 523 deletions
+56 -41
View File
@@ -178,13 +178,68 @@ if (GoogleCrashpad_FOUND)
${OLIVE_TARGET}
PRIVATE
${CRASHPAD_INCLUDE_DIRS}
)
)
target_link_libraries(
${OLIVE_TARGET}
PRIVATE
${CRASHPAD_LIBRARIES}
)
set(OLIVE_CRASH_TARGET "olive-crashhandler")
set(OLIVE_CRASH_SOURCES
dialog/crashhandler/crashhandler.h
dialog/crashhandler/crashhandler.cpp
dialog/crashhandler/crashhandlermain.cpp
)
if (WIN32)
add_executable(
${OLIVE_CRASH_TARGET}
WIN32
${OLIVE_CRASH_SOURCES}
)
else()
add_executable(
${OLIVE_CRASH_TARGET}
${OLIVE_CRASH_SOURCES}
)
endif()
target_include_directories(
${OLIVE_CRASH_TARGET}
PRIVATE
${CRASHPAD_INCLUDE_DIRS}
)
target_link_libraries(
${OLIVE_CRASH_TARGET}
PRIVATE
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
${CRASHPAD_LIBRARIES}
)
set(CRASHPAD_HANDLER "crashpad_handler${CMAKE_EXECUTABLE_SUFFIX}")
set(MINIDUMP_STACKWALK "minidump_stackwalk${CMAKE_EXECUTABLE_SUFFIX}")
if(UNIX AND NOT APPLE)
install(TARGETS ${OLIVE_TARGET} ${OLIVE_CRASH_TARGET} RUNTIME DESTINATION bin)
install(PROGRAMS ${CRASHPAD_LIBRARY_DIRS}/${CRASHPAD_HANDLER} DESTINATION bin)
install(PROGRAMS ${BREAKPAD_BIN_DIR}/${MINIDUMP_STACKWALK} DESTINATION bin)
endif()
if(APPLE)
# Move crash handler executables inside Mac app bundle
add_custom_command(TARGET ${OLIVE_CRASH_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OLIVE_CRASH_TARGET} $<TARGET_FILE_DIR:${OLIVE_TARGET}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CRASHPAD_LIBRARY_DIRS}/${CRASHPAD_HANDLER} $<TARGET_FILE_DIR:${OLIVE_TARGET}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BREAKPAD_BIN_DIR}/${MINIDUMP_STACKWALK} $<TARGET_FILE_DIR:${OLIVE_TARGET}>
)
endif()
endif()
# Set compiler definitions
@@ -209,43 +264,3 @@ if(DOXYGEN_FOUND)
set(DOXYGEN_EXTRACT_PRIVATE "YES")
doxygen_add_docs(docs ALL ${OLIVE_SOURCES})
endif()
set(OLIVE_CRASH_TARGET "olive-crashhandler")
set(OLIVE_CRASH_SOURCES
dialog/crashhandler/crashhandler.h
dialog/crashhandler/crashhandler.cpp
dialog/crashhandler/crashhandlermain.cpp
)
if (WIN32)
add_executable(
${OLIVE_CRASH_TARGET}
WIN32
${OLIVE_CRASH_SOURCES}
)
else()
add_executable(
${OLIVE_CRASH_TARGET}
${OLIVE_CRASH_SOURCES}
)
endif()
target_link_libraries(
${OLIVE_CRASH_TARGET}
PRIVATE
Qt5::Core
Qt5::Gui
Qt5::Widgets
)
if(UNIX AND NOT APPLE)
install(TARGETS ${OLIVE_TARGET} ${OLIVE_CRASH_TARGET} RUNTIME DESTINATION bin)
endif()
if(APPLE)
# Move crash handler program inside Mac app bundle
add_custom_command(TARGET ${OLIVE_CRASH_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${OLIVE_CRASH_TARGET} $<TARGET_FILE_DIR:${OLIVE_TARGET}>
)
endif()
+1
View File
@@ -37,6 +37,7 @@ void AudioVisualWaveform::OverwriteSamples(SampleBufferPtr samples, int sample_r
{
if (!channels_) {
qWarning() << "Failed to write samples - channel count is zero";
return;
}
int start_index = time_to_samples(start);
+28 -6
View File
@@ -477,14 +477,19 @@ bool FFmpegDecoder::Probe(Footage *f, const QAtomicInt* cancelled)
// Retrieve metadata about the media
avformat_find_stream_info(fmt_ctx, nullptr);
QVector<StreamPtr> streams(fmt_ctx->nb_streams);
// Dump it into the Footage object
for (unsigned int i=0;i<fmt_ctx->nb_streams;i++) {
AVStream* avstream = fmt_ctx->streams[i];
// Find decoder for this stream, if it exists we can proceed
AVCodec* decoder = avcodec_find_decoder(avstream->codecpar->codec_id);
StreamPtr str;
if (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && decoder) {
bool image_is_still = false;
rational pixel_aspect_ratio;
@@ -564,7 +569,7 @@ bool FFmpegDecoder::Probe(Footage *f, const QAtomicInt* cancelled)
str = image_stream;
} else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
} else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && decoder) {
// Create an audio stream object
AudioStreamPtr audio_stream = std::make_shared<AudioStream>();
@@ -600,7 +605,7 @@ bool FFmpegDecoder::Probe(Footage *f, const QAtomicInt* cancelled)
str->set_type(Stream::kAttachment);
break;
default:
// We should never realistically get here, but we make an "invalid" stream just in case
// Fallback to an unknown stream
str->set_type(Stream::kUnknown);
break;
}
@@ -611,11 +616,27 @@ bool FFmpegDecoder::Probe(Footage *f, const QAtomicInt* cancelled)
str->set_timebase(avstream->time_base);
str->set_duration(avstream->duration);
f->add_stream(str);
streams[i] = str;
}
// As long as we can open the container and retrieve information, this was a successful probe
result = true;
// Check if we could pick up any streams in this file
bool found_valid_streams = false;
foreach (StreamPtr stream, streams) {
if (stream->type() != Stream::kUnknown) {
found_valid_streams = true;
break;
}
}
if (found_valid_streams) {
// Copy streams over
foreach (StreamPtr stream, streams) {
f->add_stream(stream);
}
result = true;
}
}
// Free all memory
@@ -1330,6 +1351,7 @@ void FFmpegDecoderInstance::RemoveFirstFrame()
FFmpegDecoderInstance::FFmpegDecoderInstance(const char *filename, int stream_index) :
fmt_ctx_(nullptr),
codec_ctx_(nullptr),
opts_(nullptr),
scale_ctx_(nullptr),
scale_divider_(0),
+27 -2
View File
@@ -68,11 +68,17 @@ bool OIIODecoder::Probe(Footage *f, const QAtomicInt *cancelled)
// Heuristically determine whether this file is part of an image sequence or not
if (GetImageSequenceDigitCount(f->filename()) > 0) {
QSize dim(in->spec().width, in->spec().height);
int64_t ind = GetImageSequenceIndex(f->filename());
// Check if files around exist around it with that follow a sequence
if (QFileInfo::exists(TransformImageSequenceFileName(f->filename(), ind - 1))
|| QFileInfo::exists(TransformImageSequenceFileName(f->filename(), ind + 1))) {
QString previous_img_fn = TransformImageSequenceFileName(f->filename(), ind - 1);
QString next_img_fn = TransformImageSequenceFileName(f->filename(), ind + 1);
// GetImageDimensions will return a 0,0 size if the file doesn't exist, so it's safe to check
// both existence and matching size with this
if (GetImageDimensions(previous_img_fn) == dim || GetImageDimensions(next_img_fn) == dim) {
// We need user feedback here and since UI must occur in the UI thread (and we could be in any thread), we defer
// to the Core which will definitely be in the UI thread and block here until we get an answer from the user
QMetaObject::invokeMethod(Core::instance(),
@@ -316,6 +322,25 @@ bool OIIODecoder::FileTypeIsSupported(const QString& fn)
return true;
}
QSize OIIODecoder::GetImageDimensions(const QString &fn)
{
QSize sz;
auto in = OIIO::ImageInput::open(fn.toStdString());
if (in) {
sz.setWidth(in->spec().width);
sz.setHeight(in->spec().height);
in->close();
#if OIIO_VERSION < 10903
OIIO::ImageInput::destroy(in);
#endif
}
return sz;
}
bool OIIODecoder::OpenImageHandler(const QString &fn)
{
image_ = OIIO::ImageInput::open(fn.toStdString());
+2
View File
@@ -68,6 +68,8 @@ private:
static bool FileTypeIsSupported(const QString& fn);
static QSize GetImageDimensions(const QString& fn);
bool OpenImageHandler(const QString& fn);
void CloseImageHandle();
+2 -3
View File
@@ -23,10 +23,9 @@ set(OLIVE_SOURCES
common/clamp.h
common/commandlineparser.h
common/commandlineparser.cpp
common/crashhandler.h
common/crashhandler.cpp
common/crashpadinterface.cpp
common/crashpadinterface.h
common/crashpadinterface.cpp
common/crashpadutils.h
common/debug.h
common/debug.cpp
common/define.h
-150
View File
@@ -1,150 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "crashhandler.h"
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QProcess>
#include <QStandardPaths>
#include <QTextStream>
#include <QtGlobal>
#if defined(Q_OS_WINDOWS)
#include <Windows.h>
#include <DbgHelp.h>
#include <stdio.h>
#include <stdlib.h>
#elif defined(Q_OS_MAC) || defined(Q_OS_LINUX)
#include <execinfo.h>
#endif
#include "common/filefunctions.h"
OLIVE_NAMESPACE_ENTER
void crash_handler(int sig)
{
QString log_path = QDir(FileFunctions::GetTempFilePath()).filePath(QStringLiteral("olive_crash"));
QFile output(log_path);
output.open(QFile::WriteOnly);
QTextStream ostream(&output);
#ifdef GITHASH
ostream << "Version: " << GITHASH << "\n";
#endif
ostream << "Signal: " << sig << "\n\n";
#if defined(Q_OS_WINDOWS)
// Use Windows stackwalk API
HANDLE process = GetCurrentProcess();
HANDLE thread = GetCurrentThread();
CONTEXT context;
memset(&context, 0, sizeof(CONTEXT));
context.ContextFlags = CONTEXT_FULL;
RtlCaptureContext(&context);
SymInitialize(process, NULL, TRUE);
DWORD image;
STACKFRAME64 stackframe;
ZeroMemory(&stackframe, sizeof(STACKFRAME64));
#ifdef _M_IX86
image = IMAGE_FILE_MACHINE_I386;
stackframe.AddrPC.Offset = context.Eip;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.Ebp;
stackframe.AddrFrame.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.Esp;
stackframe.AddrStack.Mode = AddrModeFlat;
#elif _M_X64
image = IMAGE_FILE_MACHINE_AMD64;
stackframe.AddrPC.Offset = context.Rip;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.Rsp;
stackframe.AddrFrame.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.Rsp;
stackframe.AddrStack.Mode = AddrModeFlat;
#elif _M_IA64
image = IMAGE_FILE_MACHINE_IA64;
stackframe.AddrPC.Offset = context.StIIP;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.IntSp;
stackframe.AddrFrame.Mode = AddrModeFlat;
stackframe.AddrBStore.Offset = context.RsBSP;
stackframe.AddrBStore.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.IntSp;
stackframe.AddrStack.Mode = AddrModeFlat;
#endif
for (int i = 0; i < 50; i++) {
BOOL result = StackWalk64(
image, process, thread,
&stackframe, &context, NULL,
SymFunctionTableAccess64, SymGetModuleBase64, NULL);
if (!result) { break; }
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
symbol->MaxNameLen = MAX_SYM_NAME;
DWORD64 displacement = 0;
ostream << "[" << i << "] ";
if (SymFromAddr(process, stackframe.AddrPC.Offset, &displacement, symbol)) {
ostream << symbol->Name;
//printf("[%i] %s\n", i, symbol->Name);
} else {
ostream << "???";
//printf("[%i] ???\n", i);
}
ostream << "\n";
}
SymCleanup(process);
#elif defined(Q_OS_MAC) || defined(Q_OS_LINUX)
void *array[10];
size_t size;
// get void*'s for all entries on the stack
size = backtrace(array, 10);
// print out all the frames to stderr
backtrace_symbols_fd(array, size, output.handle());
#endif
output.close();
QString crash_handler_exe = QDir(qApp->applicationDirPath()).filePath(QStringLiteral("olive-crashhandler"));
QProcess::startDetached(crash_handler_exe, {log_path});
exit(1);
}
OLIVE_NAMESPACE_EXIT
+39 -40
View File
@@ -23,71 +23,67 @@
#ifdef USE_CRASHPAD
#include <QCoreApplication>
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
#include <QProcess>
#include "crashpadutils.h"
#include "filefunctions.h"
#ifdef Q_OS_WINDOWS
#ifdef OS_WIN
#include <Windows.h>
#endif
// Copied from base::FilePath to match its macro
#if defined(OS_POSIX)
// On most platforms, native pathnames are char arrays, and the encoding
// may or may not be specified. On Mac OS X, native pathnames are encoded
// in UTF-8.
#define TO_BASE_STRING_TYPE(x) x.toStdString()
#elif defined(OS_WIN)
// On Windows, for Unicode-aware applications, native pathnames are wchar_t
// arrays encoded in UTF-16.
#define TO_BASE_STRING_TYPE(x) x.toStdWString()
#endif // OS_WIN
crashpad::CrashpadClient *client;
bool ShowCrashConfirmation()
QString GenerateReportPath()
{
QString msg = QCoreApplication::translate("CrashReport",
"We're sorry, Olive has crashed. "
"Would you like to send an error report to "
"help developers fix this issue?\n\n"
"Crash reports are anonymous and only send "
"non-specific details about your computer and"
"how the crash occurred.");
return (QMessageBox::critical(nullptr,
QString(),
msg,
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes);
return QDir(OLIVE_NAMESPACE::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("reports"));
}
#ifdef Q_OS_WINDOWS
base::FilePath GenerateReportPathForCrashpad()
{
return base::FilePath(QSTRING_TO_BASE_STRING(GenerateReportPath()));
}
#if defined(OS_WIN)
LONG WINAPI Win32ExceptionHandler(_EXCEPTION_POINTERS *ExceptionInfo)
{
if (ShowCrashConfirmation()) {
client->DumpAndCrash(ExceptionInfo);
}
QString crash_handler_exe = QDir(qApp->applicationDirPath()).filePath(QStringLiteral("olive-crashhandler"));
QProcess::startDetached(crash_handler_exe, {GenerateReportPath(), QString::number(QDateTime::currentSecsSinceEpoch())});
client->DumpAndCrash(ExceptionInfo);
return EXCEPTION_CONTINUE_SEARCH;
}
#elif defined(OS_LINUX)
bool LinuxExceptionHandler(int, siginfo_t*, ucontext_t*)
{
QString crash_handler_exe = QDir(qApp->applicationDirPath()).filePath(QStringLiteral("olive-crashhandler"));
QProcess::startDetached(crash_handler_exe, {GenerateReportPath(), QString::number(QDateTime::currentSecsSinceEpoch())});
// Returning false signals to Crashpad to proceed with its own exception handling
return false;
}
#endif
bool InitializeCrashpad()
{
QString exe_dir = QCoreApplication::applicationDirPath();
#ifdef OS_WIN
base::FilePath handler(QSTRING_TO_BASE_STRING(QDir(exe_dir).filePath(QStringLiteral("crashpad_handler.exe"))));
#else
// FIXME: On Linux, probably should put this in a subdir so that it doesn't conflict with
// anything else in /usr/bin
base::FilePath handler(QSTRING_TO_BASE_STRING(QDir(exe_dir).filePath(QStringLiteral("crashpad_handler"))));
#endif
base::FilePath handler(TO_BASE_STRING_TYPE(QDir(exe_dir).filePath(QStringLiteral("crashpad_handler.exe"))));
base::FilePath reports_dir = GenerateReportPathForCrashpad();
base::FilePath reports_dir(TO_BASE_STRING_TYPE(QDir(OLIVE_NAMESPACE::FileFunctions::GetTempFilePath()).filePath("reports")));
base::FilePath metrics_dir(TO_BASE_STRING_TYPE(QDir(OLIVE_NAMESPACE::FileFunctions::GetTempFilePath()).filePath("metrics")));
std::string url = "https://olivevideoeditor.org/crashpad/report.php";
base::FilePath metrics_dir(QSTRING_TO_BASE_STRING(QDir(OLIVE_NAMESPACE::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("metrics"))));
// Metadata that will be posted to the server with the crash report map
std::map<std::string, std::string> annotations;
@@ -101,19 +97,22 @@ bool InitializeCrashpad()
std::unique_ptr<crashpad::CrashReportDatabase> database = crashpad::CrashReportDatabase::Initialize(reports_dir);
if (database == NULL) return false;
// Enable automated crash uploads
// Disable automated crash uploads
crashpad::Settings *settings = database->GetSettings();
if (settings == NULL) return false;
settings->SetUploadsEnabled(true);
settings->SetUploadsEnabled(false);
// Start crash handler
client = new crashpad::CrashpadClient();
bool status = client->StartHandler(handler, reports_dir, metrics_dir,
url, annotations, arguments, true, true);
"https://olivevideoeditor.org/crashpad/report.php",
annotations, arguments, true, true);
// Override Crashpad exception filter with our own
#ifdef Q_OS_WINDOWS
#if defined(OS_WIN)
SetUnhandledExceptionFilter(Win32ExceptionHandler);
#elif defined(OS_LINUX)
crashpad::CrashpadClient::SetFirstChanceExceptionHandler(LinuxExceptionHandler);
#endif
return status;
-1
View File
@@ -23,7 +23,6 @@
#ifdef USE_CRASHPAD
#include <client/crashpad_client.h>
#include <client/crash_report_database.h>
#include <client/settings.h>
+40
View File
@@ -0,0 +1,40 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef CRASHPADUTILS_H
#define CRASHPADUTILS_H
#include <client/crashpad_client.h>
// Copied from base::FilePath to match its macro
#if defined(OS_POSIX)
// On most platforms, native pathnames are char arrays, and the encoding
// may or may not be specified. On Mac OS X, native pathnames are encoded
// in UTF-8.
#define QSTRING_TO_BASE_STRING(x) x.toStdString()
#define BASE_STRING_TO_QSTRING(x) QString::fromStdString(x)
#elif defined(OS_WIN)
// On Windows, for Unicode-aware applications, native pathnames are wchar_t
// arrays encoded in UTF-16.
#define QSTRING_TO_BASE_STRING(x) x.toStdWString()
#define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x)
#endif // OS_WIN
#endif // CRASHPADUTILS_H
+9 -1
View File
@@ -51,6 +51,7 @@
#include "render/pixelformat.h"
#include "render/shaderinfo.h"
#include "task/project/import/import.h"
#include "task/project/import/importerrordialog.h"
#include "task/project/load/load.h"
#include "task/project/save/save.h"
#include "task/taskmanager.h"
@@ -473,7 +474,14 @@ void Core::AddOpenProjectFromTask(Task *task)
void Core::ImportTaskComplete(Task* task)
{
QUndoCommand *command = static_cast<ProjectImportTask*>(task)->GetCommand();
ProjectImportTask* import_task = static_cast<ProjectImportTask*>(task);
QUndoCommand *command = import_task->GetCommand();
if (import_task->HasInvalidFiles()) {
ProjectImportErrorDialog d(import_task->GetInvalidFiles(), main_window_);
d.exec();
}
undo_stack_.pushIfHasChildren(command);
}
+148 -33
View File
@@ -20,66 +20,181 @@
#include "crashhandler.h"
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QFontDatabase>
#include <QLabel>
#include <QDialogButtonBox>
#include <QHttpMultiPart>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QProcess>
#include <QScrollBar>
#include <QTextEdit>
#include <QThread>
#include <QTimer>
#include <QVBoxLayout>
#include "common/crashpadutils.h"
OLIVE_NAMESPACE_ENTER
CrashHandlerDialog::CrashHandlerDialog(const char *log_file)
CrashHandlerDialog::CrashHandlerDialog(const char *report_dir, const char* crash_time)
{
setWindowTitle(tr("Olive"));
crash_time_ = QString(crash_time).toULongLong();
report_dir_ = report_dir;
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(tr("We're sorry, Olive has crashed. Please send the following log to the developers to "
"help resolve this.")));
layout->addWidget(new QLabel(tr("We're sorry, Olive has crashed. Please help us fix it by "
"sending an error report.")));
QTextEdit* edit = new QTextEdit();
edit->setReadOnly(true);
layout->addWidget(edit);
summary_edit_ = new QTextEdit();
summary_edit_->setPlaceholderText(tr("Describe what you were doing in as much detail as "
"possible. If you can, provide steps to reproduce this crash."));
edit->append(QStringLiteral("Build Environment: %1 (%2)").arg(QSysInfo::buildCpuArchitecture(), QSysInfo::buildAbi()));
edit->append(QStringLiteral("Run Environment: %1").arg(QSysInfo::currentCpuArchitecture()));
edit->append(QStringLiteral("Kernel: %1 %2").arg(QSysInfo::kernelType(), QSysInfo::kernelVersion()));
edit->append(QStringLiteral("System: %1 (%2 %3)").arg(QSysInfo::prettyProductName(), QSysInfo::productType(), QSysInfo::productVersion()));
edit->append(QString());
layout->addWidget(summary_edit_);
QDialogButtonBox* buttons = new QDialogButtonBox();
layout->addWidget(new QLabel(tr("Crash Report:")));
// FIXME: Implement auto-reporting
//buttons->addButton(tr("Send Error Report"), QDialogButtonBox::AcceptRole);
//buttons->addButton(tr("Don't Send"), QDialogButtonBox::RejectRole);
buttons->addButton(QDialogButtonBox::Ok);
crash_report_ = new QTextEdit();
crash_report_->setReadOnly(true);
crash_report_->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
layout->addWidget(crash_report_);
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
layout->addWidget(buttons);
QHBoxLayout* btn_layout = new QHBoxLayout();
btn_layout->setMargin(0);
btn_layout->addStretch();
QFile log(log_file);
if (log.open(QFile::ReadOnly | QFile::Text)) {
edit->append(log.readAll());
send_report_btn_ = new QPushButton(tr("Send Error Report"));
connect(send_report_btn_, &QPushButton::clicked, this, &CrashHandlerDialog::SendErrorReport);
btn_layout->addWidget(send_report_btn_);
QMetaObject::invokeMethod(edit->verticalScrollBar(),
"setValue",
Qt::QueuedConnection,
Q_ARG(int, 0));
dont_send_btn_ = new QPushButton(tr("Don't Send"));
connect(dont_send_btn_, &QPushButton::clicked, this, &CrashHandlerDialog::reject);
btn_layout->addWidget(dont_send_btn_);
log.close();
layout->addLayout(btn_layout);
crash_report_->setEnabled(false);
send_report_btn_->setEnabled(false);
crash_report_->setText(tr("Waiting for crash report to be generated..."));
AttemptToFindReport();
}
void CrashHandlerDialog::SetGUIObjectsEnabled(bool e)
{
summary_edit_->setEnabled(e);
crash_report_->setEnabled(e);
send_report_btn_->setEnabled(e);
dont_send_btn_->setEnabled(e);
}
void CrashHandlerDialog::GenerateReport()
{
QProcess* p = new QProcess();
connect(p, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &CrashHandlerDialog::ReadProcessFinished);
connect(p, &QProcess::readyReadStandardOutput, this, &CrashHandlerDialog::ReadProcessHasData);
QString stackwalk_filename;
#if defined(OS_WIN)
stackwalk_filename = QStringLiteral("minidump_stackwalk.exe");
#else
stackwalk_filename = QStringLiteral("minidump_stackwalk");
#endif
QString stackwalk_bin = QDir(qApp->applicationDirPath()).filePath(stackwalk_filename);
p->start(stackwalk_bin, {report_filename_});
crash_report_->setText(QStringLiteral("Trying to run: %1").arg(stackwalk_bin));
}
void CrashHandlerDialog::ReplyFinished(QNetworkReply* reply)
{
if (reply->error() == QNetworkReply::NoError) {
// Close dialog
QDialog::accept();
} else {
QMessageBox::critical(this, tr("Upload Failed"),
tr("Failed to send error report. Please try again later."),
QMessageBox::Ok);
SetGUIObjectsEnabled(true);
}
}
void CrashHandlerDialog::accept()
void CrashHandlerDialog::AttemptToFindReport()
{
QDialog::accept();
// Retrieve reports from Crashpad database
std::unique_ptr<crashpad::CrashReportDatabase> database = crashpad::CrashReportDatabase::Initialize(base::FilePath(QSTRING_TO_BASE_STRING(QString(report_dir_))));
std::vector<crashpad::CrashReportDatabase::Report> reports;
database->GetCompletedReports(&reports);
// Find report that was made after the crash time
foreach (const crashpad::CrashReportDatabase::Report& report, reports) {
if (report.creation_time >= crash_time_) {
report_filename_ = BASE_STRING_TO_QSTRING(report.file_path.value());
break;
}
}
// If we found it, use it, otherwise wait a second and try again
if (report_filename_.isEmpty()) {
// Couldn't find report, try again in one second
QTimer::singleShot(500, this, &CrashHandlerDialog::AttemptToFindReport);
} else {
GenerateReport();
}
}
void CrashHandlerDialog::reject()
void CrashHandlerDialog::ReadProcessHasData()
{
QDialog::reject();
report_data_.append(static_cast<QProcess*>(sender())->readAllStandardOutput());
}
void CrashHandlerDialog::ReadProcessFinished()
{
SetGUIObjectsEnabled(true);
crash_report_->setText(report_data_);
delete sender();
}
void CrashHandlerDialog::SendErrorReport()
{
SetGUIObjectsEnabled(false);
QNetworkAccessManager* manager = new QNetworkAccessManager();
connect(manager, &QNetworkAccessManager::finished, this, &CrashHandlerDialog::ReplyFinished);
QNetworkRequest request;
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
request.setUrl(QStringLiteral("https://olivevideoeditor.org/crashpad/report.php"));
// Create HTTP form
QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
// Create description section
QHttpPart desc_part;
desc_part.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("text/plain"));
desc_part.setHeader(QNetworkRequest::ContentDispositionHeader, QStringLiteral("form-data; name=\"description\""));
desc_part.setBody(summary_edit_->toPlainText().toUtf8());
multipart->append(desc_part);
// Create file section
QHttpPart file_part;
file_part.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/octet-stream"));
file_part.setHeader(QNetworkRequest::ContentDispositionHeader, QStringLiteral("form-data; name=\"upload_file_minidump\"; filename=\"%1\"")
.arg(QFileInfo(report_filename_).fileName()));
QFile* file = new QFile(report_filename_);
file->open(QFile::ReadOnly);
file_part.setBodyDevice(file);
file->setParent(multipart); // Delete file with multipart
multipart->append(file_part);
manager->post(request, multipart);
}
OLIVE_NAMESPACE_EXIT
+36 -4
View File
@@ -21,7 +21,12 @@
#ifndef CRASHHANDLERDIALOG_H
#define CRASHHANDLERDIALOG_H
#include <client/crash_report_database.h>
#include <QDialog>
#include <QDialogButtonBox>
#include <QNetworkReply>
#include <QPushButton>
#include <QTextEdit>
#include "common/define.h"
@@ -31,12 +36,39 @@ class CrashHandlerDialog : public QDialog
{
Q_OBJECT
public:
CrashHandlerDialog(const char* log_file);
CrashHandlerDialog(const char* report_dir, const char* crash_time);
public slots:
virtual void accept() override;
private:
void SetGUIObjectsEnabled(bool e);
virtual void reject() override;
void GenerateReport();
QTextEdit* summary_edit_;
QTextEdit* crash_report_;
QPushButton* send_report_btn_;
QPushButton* dont_send_btn_;
QString report_filename_;
time_t crash_time_;
QString report_dir_;
QByteArray report_data_;
private slots:
void ReplyFinished(QNetworkReply *reply);
void AttemptToFindReport();
void ReadProcessHasData();
void ReadProcessFinished();
void SendErrorReport();
};
+2 -2
View File
@@ -24,13 +24,13 @@
int main(int argc, char *argv[])
{
if (argc < 2) {
if (argc < 3) {
return 1;
}
QApplication a(argc, argv);
OLIVE_NAMESPACE::CrashHandlerDialog chd(argv[1]);
OLIVE_NAMESPACE::CrashHandlerDialog chd(argv[1], argv[2]);
chd.open();
return a.exec();
+1
View File
@@ -51,6 +51,7 @@ Block::Block() :
speed_input_ = new NodeInput("speed_in", NodeParam::kFloat);
speed_input_->set_standard_value(1.0);
speed_input_->set_property(QStringLiteral("view"), QStringLiteral("percent"));
AddInput(speed_input_);
// A block's length must be greater than 0
+5 -3
View File
@@ -248,8 +248,8 @@ NodeValueTable MathNodeBase::ValueInternal(NodeValueDatabase &value, Operation o
SampleBufferPtr mixed_samples = SampleBuffer::CreateAllocated(samples_a->audio_params(), max_samples);
// Mix samples that are in both buffers
for (int i=0;i<mixed_samples->audio_params().channel_count();i++) {
// Mix samples that are in both buffers
for (int j=0;j<min_samples;j++) {
mixed_samples->data()[i][j] = PerformAll<float, float>(operation, samples_a->data()[i][j], samples_b->data()[i][j]);
}
@@ -259,9 +259,11 @@ NodeValueTable MathNodeBase::ValueInternal(NodeValueDatabase &value, Operation o
// Fill in remainder space with 0s
int remainder = max_samples - min_samples;
SampleBufferPtr larger_buffer = (max_samples == samples_a->sample_count()) ? samples_a : samples_b;
for (int i=0;i<mixed_samples->audio_params().channel_count();i++) {
memset(mixed_samples->data()[i] + min_samples * sizeof(float),
0,
memcpy(&mixed_samples->data()[i][min_samples],
&larger_buffer->data()[i][min_samples],
remainder * sizeof(float));
}
}
+4
View File
@@ -268,6 +268,10 @@ void Sequence::set_parameters_from_footage(const QList<Footage *> footage)
foreach (Footage* f, footage) {
foreach (StreamPtr s, f->streams()) {
if (!s->enabled()) {
continue;
}
switch (s->type()) {
case Stream::kVideo:
{
+6 -7
View File
@@ -375,13 +375,6 @@ void RenderBackend::RunNextJob()
return;
}
// Check if params are valid
if (!video_params_.is_valid()
|| !audio_params_.is_valid()) {
qDebug() << "Failed to run job, parameters are invalid";
return;
}
// If we have a value update queued, check if all workers are available and proceed from there
if (autocache_enabled_ && !graph_update_queue_.isEmpty()) {
bool all_workers_available = true;
@@ -449,6 +442,8 @@ void RenderBackend::RunNextJob()
switch (ticket->GetType()) {
case RenderTicket::kTypeHash:
Q_ASSERT(video_params_.is_valid());
QtConcurrent::run(&thread_pool_,
worker,
&RenderWorker::Hash,
@@ -458,6 +453,8 @@ void RenderBackend::RunNextJob()
break;
case RenderTicket::kTypeVideo:
{
Q_ASSERT(video_params_.is_valid());
rational frame = ticket->GetTime().value<rational>();
QtConcurrent::run(&thread_pool_,
@@ -474,6 +471,8 @@ void RenderBackend::RunNextJob()
break;
}
case RenderTicket::kTypeAudio:
Q_ASSERT(audio_params_.is_valid());
QtConcurrent::run(&thread_pool_,
worker,
&RenderWorker::RenderAudio,
+6 -1
View File
@@ -358,12 +358,17 @@ void FrameHashCache::HashDeleted(const QString& s, const QByteArray &hash)
return;
}
TimeRangeList ranges_to_invalidate;
QMap<rational, QByteArray>::const_iterator i;
for (i=time_hash_map_.constBegin(); i!=time_hash_map_.constEnd(); i++) {
if (i.value() == hash) {
Invalidate(TimeRange(i.key(), i.key() + timebase_));
ranges_to_invalidate.InsertTimeRange(TimeRange(i.key(), i.key() + timebase_));
}
}
foreach (const TimeRange& range, ranges_to_invalidate) {
Invalidate(range);
}
}
void FrameHashCache::ProjectInvalidated(Project *p)
+2
View File
@@ -18,5 +18,7 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
task/project/import/import.h
task/project/import/import.cpp
task/project/import/importerrordialog.h
task/project/import/importerrordialog.cpp
PARENT_SCOPE
)
+5 -2
View File
@@ -122,7 +122,10 @@ void ProjectImportTask::Import(Folder *folder, const QFileInfoList &import, int
f->set_project(nullptr);
if (f->status() != Footage::kInvalid) {
if (f->status() == Footage::kInvalid) {
// Add to list so we can tell the user about it later
invalid_files_.append(file_info.absoluteFilePath());
} else {
// Create undoable command that adds the items to the model
new ProjectViewModel::AddItemCommand(model_,
folder,
@@ -132,7 +135,7 @@ void ProjectImportTask::Import(Folder *folder, const QFileInfoList &import, int
counter++;
emit ProgressChanged((counter * 100) / file_count_);
emit ProgressChanged(static_cast<double>(counter) / static_cast<double>(file_count_));
}
}
+12
View File
@@ -42,6 +42,16 @@ public:
return command_;
}
const QStringList& GetInvalidFiles() const
{
return invalid_files_;
}
bool HasInvalidFiles() const
{
return !invalid_files_.isEmpty();
}
protected:
virtual bool Run() override;
@@ -58,6 +68,8 @@ private:
int file_count_;
QStringList invalid_files_;
};
OLIVE_NAMESPACE_EXIT
@@ -0,0 +1,53 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "importerrordialog.h"
#include <QDialogButtonBox>
#include <QLabel>
#include <QListWidget>
#include <QVBoxLayout>
OLIVE_NAMESPACE_ENTER
ProjectImportErrorDialog::ProjectImportErrorDialog(const QStringList& filenames, QWidget* parent) :
QDialog(parent)
{
QVBoxLayout* layout = new QVBoxLayout(this);
setWindowTitle(tr("Import Error"));
layout->addWidget(new QLabel(tr("The following files failed to import. Olive likely does not "
"support their formats.")));
QListWidget* list_widget = new QListWidget();
foreach (const QString& s, filenames) {
list_widget->addItem(s);
}
layout->addWidget(list_widget);
QDialogButtonBox* buttons = new QDialogButtonBox();
buttons->setStandardButtons(QDialogButtonBox::Ok);
buttons->setCenterButtons(true);
connect(buttons, &QDialogButtonBox::accepted, this, &ProjectImportErrorDialog::accept);
layout->addWidget(buttons);
}
OLIVE_NAMESPACE_EXIT
@@ -18,15 +18,23 @@
***/
#ifndef CRASHHANDLER_H
#define CRASHHANDLER_H
#ifndef PROJECTIMPORTERRORDIALOG_H
#define PROJECTIMPORTERRORDIALOG_H
#include <QDialog>
#include "common/define.h"
OLIVE_NAMESPACE_ENTER
void crash_handler(int sig);
class ProjectImportErrorDialog : public QDialog
{
Q_OBJECT
public:
ProjectImportErrorDialog(const QStringList& filenames, QWidget* parent = nullptr);
};
OLIVE_NAMESPACE_EXIT
#endif // CRASHHANDLER_H
#endif // PROJECTIMPORTERRORDIALOG_H
@@ -136,6 +136,9 @@ void NodeParamView::SelectNodes(const QList<Node *> &nodes)
connect(item, &NodeParamViewItem::InputDoubleClicked, this, &NodeParamView::InputDoubleClicked);
connect(item, &NodeParamViewItem::RequestSelectNode, this, &NodeParamView::RequestSelectNode);
// Set time target
item->SetTimeTarget(GetTimeTarget());
items_.insert(n, item);
}
+6 -4
View File
@@ -51,10 +51,12 @@ SliderLabel::SliderLabel(QWidget *parent) :
void SliderLabel::mousePressEvent(QMouseEvent *e)
{
if (e->modifiers() & Qt::AltModifier) {
emit RequestReset();
} else {
emit LabelPressed();
if (e->button() == Qt::LeftButton) {
if (e->modifiers() & Qt::AltModifier) {
emit RequestReset();
} else {
emit LabelPressed();
}
}
}
+10 -3
View File
@@ -103,9 +103,7 @@ void SliderLadder::mouseReleaseEvent(QMouseEvent *event)
{
Q_UNUSED(event)
drag_timer_.stop();
emit Released();
this->close();
}
void SliderLadder::showEvent(QShowEvent *event)
@@ -115,6 +113,15 @@ void SliderLadder::showEvent(QShowEvent *event)
drag_timer_.start();
}
void SliderLadder::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event)
drag_timer_.stop();
emit Released();
}
void SliderLadder::TimerUpdate()
{
int32_t x_mvmt, y_mvmt;
+2
View File
@@ -75,6 +75,8 @@ protected:
virtual void showEvent(QShowEvent *event) override;
virtual void closeEvent(QCloseEvent* event) override;
signals:
void DraggedByValue(int value, double multiplier);
@@ -46,6 +46,7 @@ TimelineView::TimelineView(Qt::Alignment vertical_alignment, QWidget *parent) :
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setBackgroundRole(QPalette::Window);
setContextMenuPolicy(Qt::CustomContextMenu);
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
viewport()->setMouseTracking(true);
}
+20 -31
View File
@@ -33,8 +33,10 @@ FootageViewerWidget::FootageViewerWidget(QWidget *parent) :
footage_(nullptr)
{
video_node_ = new VideoInput();
sequence_.AddNode(video_node_);
audio_node_ = new AudioInput();
viewer_node_ = new ViewerOutput();
sequence_.AddNode(audio_node_);
connect(display_widget(), &ViewerDisplayWidget::DragStarted, this, &FootageViewerWidget::StartFootageDrag);
@@ -55,17 +57,29 @@ void FootageViewerWidget::SetFootage(Footage *footage)
ConnectViewerNode(nullptr);
NodeParam::DisconnectEdge(video_node_->output(), viewer_node_->texture_input());
NodeParam::DisconnectEdge(audio_node_->output(), viewer_node_->samples_input());
NodeParam::DisconnectEdge(video_node_->output(), sequence_.viewer_output()->texture_input());
NodeParam::DisconnectEdge(audio_node_->output(), sequence_.viewer_output()->samples_input());
}
footage_ = footage;
if (footage_) {
// Update sequence media name
sequence_.viewer_output()->set_media_name(footage_->name());
// Reset parameters and then attempt to set from footage
sequence_.set_default_parameters();
sequence_.set_parameters_from_footage({footage_});
// Use first of each stream
VideoStreamPtr video_stream = nullptr;
AudioStreamPtr audio_stream = nullptr;
foreach (StreamPtr s, footage_->streams()) {
if (!s->enabled()) {
continue;
}
if (!audio_stream && s->type() == Stream::kAudio) {
audio_stream = std::static_pointer_cast<AudioStream>(s);
}
@@ -80,42 +94,17 @@ void FootageViewerWidget::SetFootage(Footage *footage)
}
}
viewer_node_->set_media_name(footage_->name());
if (video_stream) {
video_node_->SetFootage(video_stream);
viewer_node_->set_video_params(VideoParams(video_stream->width(),
video_stream->height(),
video_stream->frame_rate().flipped(),
static_cast<PixelFormat::Format>(Config::Current()["DefaultSequencePreviewFormat"].toInt()),
video_stream->pixel_aspect_ratio(),
video_stream->interlacing(),
VideoParams::generate_auto_divider(video_stream->width(), video_stream->height())));
NodeParam::ConnectEdge(video_node_->output(), viewer_node_->texture_input());
} else {
int width = Config::Current()["DefaultSequenceWidth"].toInt();
int height = Config::Current()["DefaultSequenceHeight"].toInt();
viewer_node_->set_video_params(VideoParams(width,
height,
Config::Current()["DefaultSequenceFrameRate"].value<rational>(),
static_cast<PixelFormat::Format>(Config::Current()["DefaultSequencePreviewFormat"].toInt()),
Config::Current()["DefaultSequencePixelAspect"].value<rational>(),
Config::Current()["DefaultSequenceInterlacing"].value<VideoParams::Interlacing>(),
VideoParams::generate_auto_divider(width, height)));
NodeParam::ConnectEdge(video_node_->output(), sequence_.viewer_output()->texture_input());
}
if (audio_stream) {
audio_node_->SetFootage(audio_stream);
viewer_node_->set_audio_params(AudioParams(audio_stream->sample_rate(), audio_stream->channel_layout(), SampleFormat::kInternalFormat));
NodeParam::ConnectEdge(audio_node_->output(), viewer_node_->samples_input());
} else {
viewer_node_->set_audio_params(AudioParams(Config::Current()["DefaultSequenceAudioFrequency"].toInt(),
Config::Current()["DefaultSequenceAudioLayout"].toULongLong(),
SampleFormat::kInternalFormat));
NodeParam::ConnectEdge(audio_node_->output(), sequence_.viewer_output()->samples_input());
}
ConnectViewerNode(viewer_node_, footage_->project()->color_manager());
ConnectViewerNode(sequence_.viewer_output(), footage_->project()->color_manager());
SetTimestamp(cached_timestamps_.value(footage_, 0));
}
+2 -2
View File
@@ -47,12 +47,12 @@ private:
Footage* footage_;
Sequence sequence_;
VideoInput* video_node_;
AudioInput* audio_node_;
ViewerOutput* viewer_node_;
QHash<Footage*, int64_t> cached_timestamps_;
private slots:
+3 -1
View File
@@ -566,7 +566,9 @@ QString ViewerWidget::GetCachedFilenameFromTime(const rational &time)
bool ViewerWidget::FrameExistsAtTime(const rational &time)
{
return GetConnectedNode() && time >= 0 && time < GetConnectedNode()->video_frame_cache()->GetLength();
return GetConnectedNode()
&& ((time >= 0 && time < GetConnectedNode()->video_frame_cache()->GetLength())
|| GetConnectedNode()->video_frame_cache()->GetLength().isNull());
}
void ViewerWidget::SetDisplayImage(FramePtr frame, bool main_only)
+16
View File
@@ -349,6 +349,22 @@ void MainWindow::ProjectClose(Project *p)
CloseSequence(seq);
}
}
// Close any open footage in footage viewer
QList<ItemPtr> footage = p->get_items_of_type(Item::kFootage);
QList<Footage*> footage_in_viewer = footage_viewer_panel_->GetSelectedFootage();
if (!footage_in_viewer.isEmpty()) {
// FootageViewer only has the one footage item
Footage* f = footage_in_viewer.first();
foreach (ItemPtr i, footage) {
if (f == i.get()) {
footage_viewer_panel_->SetFootage(nullptr);
break;
}
}
}
}
void MainWindow::SetApplicationProgressStatus(ProgressStatus status)