diff --git a/aegilib/aegilib_2008.vcproj b/aegilib/aegilib_2008.vcproj
index a634080c8..bd56ef584 100644
--- a/aegilib/aegilib_2008.vcproj
+++ b/aegilib/aegilib_2008.vcproj
@@ -96,7 +96,7 @@
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="2"
+ ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
@@ -119,6 +119,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="2"
+ InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="false"
@@ -146,15 +147,11 @@
Name="VCPreLinkEventTool"
/>
-
@@ -164,9 +161,6 @@
-
@@ -279,10 +273,6 @@
RelativePath=".\include\aegilib\range.h"
>
-
-
@@ -396,7 +386,7 @@
>
+
+
+
+
diff --git a/aegilib/include/athenasub/api.h b/aegilib/include/athenasub/api.h
index 542c8e5a0..4cbaa186c 100644
--- a/aegilib/include/athenasub/api.h
+++ b/aegilib/include/athenasub/api.h
@@ -33,7 +33,7 @@
// Contact: mailto:amz@aegisub.net
//
-#define ATHENA_DLL
+//#define ATHENA_DLL
#ifdef ATHENA_DLL
#ifdef ATHENA_EXPORTS
#define ATHENA_API __declspec(dllexport)
diff --git a/aegilib/include/athenasub/interfaces.h b/aegilib/include/athenasub/interfaces.h
index 02b71799f..304605dc4 100644
--- a/aegilib/include/athenasub/interfaces.h
+++ b/aegilib/include/athenasub/interfaces.h
@@ -253,15 +253,6 @@ namespace Athenasub {
virtual String GetDefaultGroup() const = 0;
virtual Entry Clone() const = 0;
-
- /*
- static PlainText GetAsPlain(Entry ptr);
- static Dialogue GetAsDialogue(Entry ptr);
- static DialogueConst GetAsDialogue(EntryConst ptr);
- static Style GetAsStyle(Entry ptr);
- static Attachment GetAsFile(Entry ptr);
- static RawEntry GetAsRaw(Entry ptr);
- */
};
@@ -298,8 +289,8 @@ namespace Athenasub {
// Write accessors
virtual void SetText(const String& text) = 0;
- virtual void SetStartTime(Time start) = 0;
- virtual void SetEndTime(Time end) = 0;
+ virtual void SetStartTime(const ITime& start) = 0;
+ virtual void SetEndTime(const ITime& end) = 0;
virtual void SetStartFrame(int start) = 0;
virtual void SetEndFrame(int end) = 0;
virtual void SetComment(bool isComment) = 0;
diff --git a/aegilib/src/action.h b/aegilib/src/action.h
index 7ae234b29..6701cbdd4 100644
--- a/aegilib/src/action.h
+++ b/aegilib/src/action.h
@@ -49,7 +49,6 @@ namespace Athenasub {
public:
ActionInsert(Entry entry,int line,const String §ion);
- ~ActionInsert() {}
Action GetAntiAction(const IModel& model) const;
void Execute(IModel& model);
@@ -63,7 +62,6 @@ namespace Athenasub {
public:
ActionRemove(int line,const String §ion);
- ~ActionRemove() {}
Action GetAntiAction(const IModel& model) const;
void Execute(IModel& model);
@@ -81,7 +79,6 @@ namespace Athenasub {
public:
ActionModify(Entry entry,int line,const String §ion,bool noTextFields);
ActionModify(shared_ptr delta,int line,const String §ion);
- ~ActionModify() {}
Action GetAntiAction(const IModel& model) const;
void Execute(IModel& model);
@@ -98,7 +95,6 @@ namespace Athenasub {
public:
ActionModifyBatch(std::vector entries,std::vector deltas,Selection selection,const String §ion,bool noTextFields);
- ~ActionModifyBatch() {}
Action GetAntiAction(const IModel& model) const;
void Execute(IModel& model);
diff --git a/aegilib/src/actionlist.cpp b/aegilib/src/actionlist.cpp
index b8b187032..79ab37006 100644
--- a/aegilib/src/actionlist.cpp
+++ b/aegilib/src/actionlist.cpp
@@ -40,7 +40,7 @@ using namespace Athenasub;
///////////////
// Constructor
-CActionList::CActionList(Model _model,String _actionName,const String _owner,bool _undoAble)
+CActionList::CActionList(weak_ptr _model,String _actionName,const String _owner,bool _undoAble)
: model(_model), owner(_owner), undoAble(_undoAble)
{
valid = false;
@@ -96,7 +96,7 @@ void CActionList::Start(const String name)
void CActionList::Finish()
{
if (valid) {
- model->ProcessActionList(*this);
+ Model(model)->ProcessActionList(*this);
actions.clear();
valid = false;
}
@@ -125,7 +125,7 @@ void CActionList::RemoveLine(int position,const String section)
// Insert a "modify line" action
Entry CActionList::ModifyLine(int position,const String section)
{
- Section sect = model->GetSection(section);
+ Section sect = Model(model)->GetSection(section);
Entry entry = sect->GetEntry(position)->Clone();
Action action = Action (new ActionModify(entry,position,section,false));
AddAction(action);
@@ -138,7 +138,7 @@ Entry CActionList::ModifyLine(int position,const String section)
std::vector CActionList::ModifyLines(Selection selection,const String section)
{
// Get section
- Section sect = model->GetSection(section);
+ Section sect = Model(model)->GetSection(section);
// Generate entries
std::vector entries(selection->GetCount());
diff --git a/aegilib/src/actionlist.h b/aegilib/src/actionlist.h
index 54ed421d8..7e4701742 100644
--- a/aegilib/src/actionlist.h
+++ b/aegilib/src/actionlist.h
@@ -56,12 +56,12 @@ namespace Athenasub {
private:
String actionName;
String owner;
- Model model;
+ weak_ptr model;
std::list actions;
bool valid;
bool undoAble;
- CActionList(Model model,const String actionName,const String owner,bool undoAble);
+ CActionList(weak_ptr,const String actionName,const String owner,bool undoAble);
void Start(const String actionName);
void AddActionStart(const Action action);
diff --git a/aegilib/src/athenatime.h b/aegilib/src/athenatime.h
index b6523ee8e..2e9687829 100644
--- a/aegilib/src/athenatime.h
+++ b/aegilib/src/athenatime.h
@@ -48,8 +48,8 @@ namespace Athenasub {
CTime() { ms = 0; }
CTime(int _ms) { ms = _ms; }
- void SetMS(int milliseconds) { ms = milliseconds; }
- int GetMS() const { return ms; }
+ inline void SetMS(int milliseconds) { ms = milliseconds; }
+ inline int GetMS() const { return ms; }
String GetString(int ms_precision,int h_precision) const;
void ParseString(const String &data);
diff --git a/aegilib/src/controller.cpp b/aegilib/src/controller.cpp
index 9dd1ef186..98fe36979 100644
--- a/aegilib/src/controller.cpp
+++ b/aegilib/src/controller.cpp
@@ -109,11 +109,15 @@ bool CController::CanRedo(const String owner) const
}
void CController::Undo(const String owner)
{
- model->Undo(owner);
+ if (CanUndo(owner)) {
+ model->Undo(owner);
+ }
}
void CController::Redo(const String owner)
{
- model->Redo(owner);
+ if (CanRedo(owner)) {
+ model->Redo(owner);
+ }
}
diff --git a/aegilib/src/formats/format_ass_dialogue.cpp b/aegilib/src/formats/format_ass_dialogue.cpp
index b68042b35..56f93ac66 100644
--- a/aegilib/src/formats/format_ass_dialogue.cpp
+++ b/aegilib/src/formats/format_ass_dialogue.cpp
@@ -142,91 +142,61 @@ bool DialogueASS::Parse(wxString rawData, int version)
// Serialize
String DialogueASS::ToText(int version) const
{
- // Old, slow code
- if (false) {
- // Prepare
- wxString final;
+ // Calculate size
+ size_t size = 9+9+20+12+12; // 9 for "comment: " (+1 for dialogue below), 9 for commas,
+ // 20 for times, 12 for margins, 12 just to be sure that layer fits
+ if (!isComment) size++; // Comment->Dialogue
+ if (version == 0) size += 8; // "Marked=0"
+ else if (version == 2) size += 5; // Fourth margin
+ for (size_t i=0;i<4;i++) size += text[i].Length();
- // Write comment or dialogue
- if (isComment) final = _T("Comment: ");
- else final = _T("Dialogue: ");
+ // Allocate string
+ wxString final;
+ wxChar *buffer = final.GetWriteBuf(size);
+ wxChar temp[16];
- // Write layer or marked
- if (version >= 1) final += wxString::Format(_T("%01i,"),layer);
- else final += _T("Marked=0,");
+ // Write comment/dialogue
+ size_t pos = 0;
+ if (isComment) WriteText(buffer,_T("Comment: "),9,pos);
+ else WriteText(buffer,_T("Dialogue: "),10,pos);
- // Write times, style and actor
- final += time[0].GetString(2,1) + _T(",") + time[1].GetString(2,1) + _T(",") + text[1] + _T(",") + text[2] + _T(",");
+ // Write layer or marked
+ if (version >= 1) {
+ WriteNumber(buffer,temp,layer,0,pos);
+ WriteChar(buffer,_T(','),pos);
+ }
+ else WriteText(buffer,_T("Marked=0,"),9,pos);
- // Write margins
- if (version <= 1) final += wxString::Format(_T("%04i,%04i,%04i,"),margin[0],margin[1],margin[2]);
- else final += wxString::Format(_T("%04i,%04i,%04i,%04i,"),margin[0],margin[1],margin[2],margin[3]);
-
- // Write effect and text
- final += text[3] + _T(",") + text[0];
-
- // Return final
- return final;
+ // Write times
+ for (size_t i=0;i<2;i++) {
+ wxString tempStr = time[i].GetString(2,1);
+ WriteText(buffer,&tempStr[0],10,pos);
+ WriteChar(buffer,_T(','),pos);
}
- // New, faster code
- else {
- // Calculate size
- size_t size = 9+9+20+12+12; // 9 for "comment: " (+1 for dialogue below), 9 for commas,
- // 20 for times, 12 for margins, 12 just to be sure that layer fits
- if (!isComment) size++; // Comment->Dialogue
- if (version == 0) size += 8; // "Marked=0"
- else if (version == 2) size += 5; // Fourth margin
- for (size_t i=0;i<4;i++) size += text[i].Length();
+ // Write style and actor
+ WriteText(buffer,&text[1][0],text[1].Length(),pos);
+ WriteChar(buffer,_T(','),pos);
+ WriteText(buffer,&text[2][0],text[2].Length(),pos);
+ WriteChar(buffer,_T(','),pos);
- // Allocate string
- wxString final;
- wxChar *buffer = final.GetWriteBuf(size);
- wxChar temp[16];
-
- // Write comment/dialogue
- size_t pos = 0;
- if (isComment) WriteText(buffer,_T("Comment: "),9,pos);
- else WriteText(buffer,_T("Dialogue: "),10,pos);
-
- // Write layer or marked
- if (version >= 1) {
- WriteNumber(buffer,temp,layer,0,pos);
- WriteChar(buffer,_T(','),pos);
- }
- else WriteText(buffer,_T("Marked=0,"),9,pos);
-
- // Write times
- for (size_t i=0;i<2;i++) {
- wxString tempStr = time[i].GetString(2,1);
- WriteText(buffer,&tempStr[0],10,pos);
- WriteChar(buffer,_T(','),pos);
- }
-
- // Write style and actor
- WriteText(buffer,&text[1][0],text[1].Length(),pos);
+ // Write margins
+ size_t marCount = 3;
+ if (version == 2) marCount++;
+ for (size_t i=0;i time;
array text; // 0 = text, 1 = style, 2 = actor, 3 = effect
+ array time;
array margin;
int layer;
bool isComment;
@@ -84,8 +84,8 @@ namespace Athenasub {
const String& GetUserField() const { return text[3]; }
// Write acessors
- void SetStartTime(Time setStart) { time[0].SetMS(setStart->GetMS()); }
- void SetEndTime(Time setEnd) { time[1].SetMS(setEnd->GetMS()); }
+ void SetStartTime(const ITime &setStart) { time[0].SetMS(setStart.GetMS()); }
+ void SetEndTime(const ITime &setEnd) { time[1].SetMS(setEnd.GetMS()); }
void SetComment(bool _isComment) { isComment = _isComment; }
void SetLayer(int _layer) { layer = _layer; }
void SetMargin(int _margin,int value) { margin.at(_margin) = value; }
diff --git a/aegilib/src/model.cpp b/aegilib/src/model.cpp
index 7a39383cd..a373e44a3 100644
--- a/aegilib/src/model.cpp
+++ b/aegilib/src/model.cpp
@@ -67,7 +67,7 @@ void CModel::ProcessActionList(CActionList &_actionList,int type)
shared_ptr actions = shared_ptr(new CActionList(_actionList));
// Setup undo
- shared_ptr undo = shared_ptr(new CActionList(actions->model,actions->actionName,actions->owner,actions->undoAble));
+ shared_ptr undo = shared_ptr(new CActionList(Model(actions->model),actions->actionName,actions->owner,actions->undoAble));
ActionStack *stack;
if (type == 1) stack = &redoStack;
else stack = &undoStack;
diff --git a/aegilib/src/section_entry_dialogue.h b/aegilib/src/section_entry_dialogue.h
index 6dfc15eaa..eb09bf31c 100644
--- a/aegilib/src/section_entry_dialogue.h
+++ b/aegilib/src/section_entry_dialogue.h
@@ -80,8 +80,8 @@ namespace Athenasub {
// Write accessors
virtual void SetText(const String& text) { (void) text; ThrowUnsupported(); }
- virtual void SetStartTime(Time start) { (void) start; ThrowUnsupported(); }
- virtual void SetEndTime(Time end) { (void) end; ThrowUnsupported(); }
+ virtual void SetStartTime(const ITime& start) { (void) start; ThrowUnsupported(); }
+ virtual void SetEndTime(const ITime& end) { (void) end; ThrowUnsupported(); }
virtual void SetStartFrame(int start) { (void) start; ThrowUnsupported(); }
virtual void SetEndFrame(int end) { (void) end; ThrowUnsupported(); }
virtual void SetComment(bool isComment) { (void) isComment; ThrowUnsupported(); }
diff --git a/aegilib/test/src/main.cpp b/aegilib/test/src/main.cpp
index c8beb940d..48821cd09 100644
--- a/aegilib/test/src/main.cpp
+++ b/aegilib/test/src/main.cpp
@@ -33,7 +33,7 @@
// Contact: mailto:amz@aegisub.net
//
-#define ATHENA_DLL
+//#define ATHENA_DLL
#include
#include
#include
@@ -92,13 +92,13 @@ int main()
// Issue an action
#ifdef WXDEBUG
- const int n = 1;
+ int n = 1;
#else
- const int n = 100;
+ int n = 100;
#endif
cout << "Executing action " << n << " times... ";
timer.Start();
- for (size_t i=0;iCreateActionList(L"Test");
Selection selection = control->CreateSelection();
selection->AddRange(Range(0,5000));
@@ -108,8 +108,8 @@ int main()
size_t len = entries.size();
for (size_t i=0;i (entries[i]);
- diag->SetStartTime(diag->GetStartTime() - 55555);
- diag->SetEndTime(diag->GetEndTime() + 5555);
+ diag->SetStartTime(*(diag->GetStartTime() - 55555));
+ diag->SetEndTime(*(diag->GetEndTime() + 5555));
}
actions->Finish();
}
@@ -117,16 +117,19 @@ int main()
cout << "Done in " << timer.Time() << " ms.\n";
// Rollback
- cout << "Undoing " << n << " times... ";
- for (size_t i=0;iUndo();
}
- cout << "Done.\n";
+ timer.Pause();
+ cout << "Done in " << timer.Time() << " ms.\n";
// Undo
- cout << "Undoing and redoing " << n*10 << " times... ";
+ n = 100;
+ cout << "Undoing and redoing " << n << " times... ";
timer.Start();
- for (size_t i=0;iUndo();
control->Redo();
}
@@ -149,5 +152,7 @@ int main()
cout << "\n\nException: " << e.what() << endl << endl;
}
+ system("pause");
+
return true;
}
diff --git a/aegilib/test/test_2008.vcproj b/aegilib/test/test_2008.vcproj
index c16649d96..119106771 100644
--- a/aegilib/test/test_2008.vcproj
+++ b/aegilib/test/test_2008.vcproj
@@ -118,6 +118,9 @@
/>