empty string fixes and working ruby support
Originally committed to SVN as r910.
This commit is contained in:
parent
44712f0d7b
commit
5ef911d93c
7 changed files with 27 additions and 28 deletions
|
@ -366,7 +366,9 @@ namespace Automation4 {
|
|||
|
||||
if (script_finished) {
|
||||
if (!debug_visible) {
|
||||
EndModal(0);
|
||||
if(IsModal())
|
||||
EndModal(0);
|
||||
else Show(false);
|
||||
} else {
|
||||
cancel_button->Enable(true);
|
||||
cancel_button->SetLabel(_("Close"));
|
||||
|
@ -450,7 +452,10 @@ namespace Automation4 {
|
|||
cancelled = true;
|
||||
cancel_button->Enable(false);
|
||||
} else {
|
||||
EndModal(0);
|
||||
if(this->IsModal())
|
||||
EndModal(0);
|
||||
else
|
||||
Show(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,6 @@ namespace Automation4 {
|
|||
void OnIdle(wxIdleEvent &evt);
|
||||
void OnConfigDialog(ShowConfigDialogEvent &evt);
|
||||
|
||||
void DoUpdateDisplay();
|
||||
|
||||
protected:
|
||||
volatile bool cancelled;
|
||||
|
@ -242,6 +241,7 @@ namespace Automation4 {
|
|||
virtual ~ProgressSink();
|
||||
|
||||
public:
|
||||
void DoUpdateDisplay();
|
||||
void SetProgress(float _progress);
|
||||
void SetTask(const wxString &_task);
|
||||
void SetTitle(const wxString &_title);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "ass_override.h"
|
||||
#include "text_file_reader.h"
|
||||
#include "options.h"
|
||||
#include "../ruby/include/ruby.h"
|
||||
#include <ruby.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/filefn.h>
|
||||
|
@ -262,6 +262,7 @@ namespace Automation4 {
|
|||
, macro_fun(macro_function)
|
||||
, validation_fun(validate_function)
|
||||
{
|
||||
no_validate = validate_function == Qnil;
|
||||
RegisterFeature();
|
||||
}
|
||||
|
||||
|
@ -273,25 +274,23 @@ namespace Automation4 {
|
|||
try {
|
||||
RubyAssFile *subsobj = new RubyAssFile(subs, true, true);
|
||||
VALUE sel = CreateIntegerArray(selected); // selected items
|
||||
// RubyObjects::Get()->Register(sel);
|
||||
RubyObjects::Get()->Register(sel);
|
||||
VALUE result = rbFunCall(rb_mKernel, rb_to_id(validation_fun), 3, subsobj->rbAssFile, sel, rb_int2inum(active));
|
||||
RubyObjects::Get()->Unregister(sel);
|
||||
if(result != Qnil && result != Qfalse)
|
||||
return true;
|
||||
// RubyObjects::Get()->Unregister(sel);
|
||||
}catch (const char* e) {
|
||||
wxString *err = new wxString(e, wxConvUTF8);
|
||||
throw err->c_str();
|
||||
wxMessageBox(*err, _T("Error running validation function"),wxICON_ERROR | wxOK);
|
||||
}
|
||||
// wxMessageBox(error, _T("Error running validation function"), wxICON_ERROR | wxOK);
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void RubyFeatureMacro::Process(AssFile *subs, const std::vector<int> &selected, int active, wxWindow * const progress_parent)
|
||||
{
|
||||
// prepare function call
|
||||
try {
|
||||
|
||||
delete RubyProgressSink::inst;
|
||||
RubyProgressSink::inst = new RubyProgressSink(progress_parent, false);
|
||||
RubyProgressSink::inst->SetTitle(GetName());
|
||||
RubyProgressSink::inst->Show(true);
|
||||
|
@ -301,19 +300,16 @@ namespace Automation4 {
|
|||
VALUE sel = CreateIntegerArray(selected); // selected items
|
||||
RubyObjects::Get()->Register(sel);
|
||||
VALUE result = rbFunCall(rb_mKernel, rb_to_id(macro_fun), 3, subsobj->rbAssFile, sel, rb_int2inum(active));
|
||||
RubyObjects::Get()->Unregister(sel);
|
||||
if(result != Qnil && result != Qfalse)
|
||||
{
|
||||
subsobj->RubyUpdateAssFile(result);
|
||||
RubyProgressSink::inst->script_finished = true;
|
||||
}
|
||||
else RubyProgressSink::inst->Show(false);
|
||||
// RubyObjects::Get()->Unregister(sel);
|
||||
} catch (const char* e) {
|
||||
wxString *err = new wxString(e, wxConvUTF8);
|
||||
wxMessageBox(*err, _T("Error running macro"),wxICON_ERROR | wxOK);
|
||||
}
|
||||
delete RubyProgressSink::inst;
|
||||
RubyProgressSink::inst = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -355,7 +351,7 @@ namespace Automation4 {
|
|||
assert(config_dialog->RubyReadBack() == 1);
|
||||
// TODO, write back stored options here
|
||||
}
|
||||
|
||||
delete RubyProgressSink::inst;
|
||||
RubyProgressSink::inst = new RubyProgressSink(export_dialog, false);
|
||||
RubyProgressSink::inst->SetTitle(GetName());
|
||||
RubyProgressSink::inst->Show(true);
|
||||
|
@ -365,15 +361,12 @@ namespace Automation4 {
|
|||
if(result != Qnil && result != Qfalse)
|
||||
{
|
||||
subsobj->RubyUpdateAssFile(result);
|
||||
RubyProgressSink::inst->script_finished = true;
|
||||
}
|
||||
// else RubyProgressSink::inst->Show(false);
|
||||
} catch (const char* e) {
|
||||
wxString *err = new wxString(e, wxConvUTF8);
|
||||
wxMessageBox(*err, _T("Error running filter"),wxICON_ERROR | wxOK);
|
||||
}
|
||||
delete RubyProgressSink::inst;
|
||||
RubyProgressSink::inst = NULL;
|
||||
|
||||
}
|
||||
|
||||
ScriptConfigDialog* RubyFeatureFilter::GenerateConfigDialog(wxWindow *parent)
|
||||
|
@ -412,10 +405,6 @@ namespace Automation4 {
|
|||
|
||||
RubyProgressSink::~RubyProgressSink()
|
||||
{
|
||||
rb_undef_method(RubyScript::RubyAegisub, "progress_set");
|
||||
rb_undef_method(RubyScript::RubyAegisub, "progress_task");
|
||||
rb_undef_method(RubyScript::RubyAegisub, "progress_title");
|
||||
rb_undef_method(RubyScript::RubyAegisub, "debug_out");
|
||||
// remove progress reporting stuff
|
||||
// TODO
|
||||
}
|
||||
|
@ -458,6 +447,7 @@ namespace Automation4 {
|
|||
wxString _m(StringValueCStr(msg), wxConvUTF8);
|
||||
RubyProgressSink::inst->AddDebugOutput(_m);
|
||||
RubyProgressSink::inst->DoUpdateDisplay();
|
||||
wxSafeYield(RubyProgressSink::inst);
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "auto4_base.h"
|
||||
#include <wx/thread.h>
|
||||
#include <wx/event.h>
|
||||
#include "../ruby/include/ruby.h"
|
||||
#include <ruby.h>
|
||||
|
||||
class wxWindow;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "ass_override.h"
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
#include "../ruby/include/ruby.h"
|
||||
#include <ruby.h>
|
||||
|
||||
|
||||
namespace Automation4 {
|
||||
|
@ -376,7 +376,8 @@ namespace Automation4 {
|
|||
new_entry = reinterpret_cast<AssEntry*>(rb_protect(rb2AssWrapper, rbEntry, &status));
|
||||
if(status == 0) ass->Line.push_back(new_entry);
|
||||
else {
|
||||
// TODO: log/display the error
|
||||
if(RubyProgressSink::inst)
|
||||
RubyProgressSink::inst->RubyDebugOut(Qnil, ruby_errinfo);
|
||||
ruby_errinfo = Qnil; // clear the error
|
||||
}
|
||||
}
|
||||
|
@ -566,6 +567,8 @@ namespace Automation4 {
|
|||
VALUE res = rb_protect(rbAss2RbWrapper, reinterpret_cast<VALUE>(*entry), &status);
|
||||
if(status == 0) rb_ary_push(rbAssFile, res);
|
||||
else {
|
||||
if(RubyProgressSink::inst)
|
||||
RubyProgressSink::inst->RubyDebugOut(Qnil, ruby_errinfo);
|
||||
ruby_errinfo = Qnil;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
|||
version = 2;
|
||||
}
|
||||
// Not-so-special case for other groups, just set it
|
||||
else if (wxbuffer[0] == _T('[')) {
|
||||
else if (!wxbuffer.IsEmpty() && wxbuffer[0] == _T('[')) {
|
||||
curgroup = wxbuffer;
|
||||
// default from extension in all other sections
|
||||
//version = 1;
|
||||
|
|
|
@ -103,6 +103,7 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na
|
|||
while (file.HasMoreLines()) {
|
||||
// Reads line
|
||||
wxString value = file.ReadLineFromFile();
|
||||
if(value.IsEmpty()) continue;
|
||||
|
||||
// Check if this isn't a timecodes file
|
||||
if (value.Left(10) == _T("# timecode")) {
|
||||
|
|
Loading…
Reference in a new issue