mirror of https://github.com/odrling/Aegisub
Re-worked the fonts collector log box to use wx's event system. If this doesn't fix the crashes, I'll try sacrificing a goat.
Originally committed to SVN as r1787.
This commit is contained in:
parent
984c2362fd
commit
f5306dc6a9
|
@ -65,6 +65,12 @@ enum IDs {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/////////
|
||||||
|
// Event
|
||||||
|
DECLARE_EVENT_TYPE(EVT_ADD_TEXT, -1)
|
||||||
|
DEFINE_EVENT_TYPE(EVT_ADD_TEXT)
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
|
DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
|
||||||
|
@ -160,12 +166,18 @@ BEGIN_EVENT_TABLE(DialogFontsCollector, wxDialog)
|
||||||
EVT_BUTTON(BROWSE_BUTTON,DialogFontsCollector::OnBrowse)
|
EVT_BUTTON(BROWSE_BUTTON,DialogFontsCollector::OnBrowse)
|
||||||
EVT_BUTTON(wxID_CLOSE,DialogFontsCollector::OnClose)
|
EVT_BUTTON(wxID_CLOSE,DialogFontsCollector::OnClose)
|
||||||
EVT_RADIOBOX(RADIO_BOX,DialogFontsCollector::OnRadio)
|
EVT_RADIOBOX(RADIO_BOX,DialogFontsCollector::OnRadio)
|
||||||
|
EVT_COMMAND(0,EVT_ADD_TEXT,DialogFontsCollector::OnAddText)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// Start processing
|
// Start processing
|
||||||
void DialogFontsCollector::OnStart(wxCommandEvent &event) {
|
void DialogFontsCollector::OnStart(wxCommandEvent &event) {
|
||||||
|
// Clear
|
||||||
|
LogBox->SetReadOnly(false);
|
||||||
|
LogBox->ClearAll();
|
||||||
|
LogBox->SetReadOnly(true);
|
||||||
|
|
||||||
// Action being done
|
// Action being done
|
||||||
int action = CollectAction->GetSelection();
|
int action = CollectAction->GetSelection();
|
||||||
|
|
||||||
|
@ -317,6 +329,23 @@ void DialogFontsCollector::Update(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// Add text
|
||||||
|
void DialogFontsCollector::OnAddText(wxCommandEvent &event) {
|
||||||
|
ColourString *str = (ColourString*) event.GetClientData();
|
||||||
|
LogBox->SetReadOnly(false);
|
||||||
|
int pos = LogBox->GetLength();
|
||||||
|
LogBox->AppendText(str->text);
|
||||||
|
if (str->colour) {
|
||||||
|
LogBox->StartStyling(pos,31);
|
||||||
|
LogBox->SetStyling(str->text.Length(),str->colour);
|
||||||
|
}
|
||||||
|
delete str;
|
||||||
|
LogBox->GotoPos(pos);
|
||||||
|
LogBox->SetReadOnly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// Collect font files
|
// Collect font files
|
||||||
void FontsCollectorThread::CollectFontData () {
|
void FontsCollectorThread::CollectFontData () {
|
||||||
|
@ -354,13 +383,6 @@ wxThread::ExitCode FontsCollectorThread::Entry() {
|
||||||
///////////
|
///////////
|
||||||
// Collect
|
// Collect
|
||||||
void FontsCollectorThread::Collect() {
|
void FontsCollectorThread::Collect() {
|
||||||
// Clear log box
|
|
||||||
wxMutexGuiEnter();
|
|
||||||
collector->LogBox->SetReadOnly(false);
|
|
||||||
collector->LogBox->ClearAll();
|
|
||||||
collector->LogBox->SetReadOnly(true);
|
|
||||||
wxMutexGuiLeave();
|
|
||||||
|
|
||||||
// Set destination folder
|
// Set destination folder
|
||||||
int oper = collector->CollectAction->GetSelection();
|
int oper = collector->CollectAction->GetSelection();
|
||||||
destFolder = collector->DestBox->GetValue();
|
destFolder = collector->DestBox->GetValue();
|
||||||
|
@ -588,19 +610,12 @@ void FontsCollectorThread::AddFont(wxString fontname,int mode) {
|
||||||
///////////////
|
///////////////
|
||||||
// Append text
|
// Append text
|
||||||
void FontsCollectorThread::AppendText(wxString text,int colour) {
|
void FontsCollectorThread::AppendText(wxString text,int colour) {
|
||||||
wxStyledTextCtrl *LogBox = collector->LogBox;
|
ColourString *str = new ColourString;
|
||||||
wxMutexGuiEnter();
|
str->text = text;
|
||||||
LogBox->SetReadOnly(false);
|
str->colour = colour;
|
||||||
int pos = LogBox->GetLength();
|
wxCommandEvent event(EVT_ADD_TEXT,0);
|
||||||
LogBox->AppendText(text);
|
event.SetClientData(str);
|
||||||
if (colour) {
|
collector->AddPendingEvent(event);
|
||||||
LogBox->StartStyling(pos,31);
|
|
||||||
LogBox->SetStyling(text.Length(),colour);
|
|
||||||
}
|
|
||||||
LogBox->GotoPos(pos);
|
|
||||||
LogBox->SetReadOnly(true);
|
|
||||||
//wxSafeYield();
|
|
||||||
wxMutexGuiLeave();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ private:
|
||||||
void OnClose(wxCommandEvent &event);
|
void OnClose(wxCommandEvent &event);
|
||||||
void OnBrowse(wxCommandEvent &event);
|
void OnBrowse(wxCommandEvent &event);
|
||||||
void OnRadio(wxCommandEvent &event);
|
void OnRadio(wxCommandEvent &event);
|
||||||
|
void OnAddText(wxCommandEvent &event);
|
||||||
void Update(int value=-1);
|
void Update(int value=-1);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -113,3 +114,11 @@ public:
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// Helper class to pass strings along
|
||||||
|
struct ColourString {
|
||||||
|
wxString text;
|
||||||
|
int colour;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue