Fix crash when pasting over
Originally committed to SVN as r4562.
This commit is contained in:
parent
8756dc1800
commit
358b2734da
3 changed files with 27 additions and 92 deletions
|
@ -34,9 +34,6 @@
|
||||||
/// @ingroup secondary_ui
|
/// @ingroup secondary_ui
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
///////////
|
|
||||||
// Headers
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
|
@ -51,12 +48,21 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
|
/// Button IDs
|
||||||
|
enum {
|
||||||
|
Paste_Over_Times = 1620,
|
||||||
|
Paste_Over_Text,
|
||||||
|
Paste_Over_All,
|
||||||
|
Paste_Over_None
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
/// @param parent
|
/// @param parent
|
||||||
///
|
///
|
||||||
DialogPasteOver::DialogPasteOver (wxWindow *parent)
|
DialogPasteOver::DialogPasteOver (wxWindow *parent, std::vector<bool>& options)
|
||||||
: wxDialog (parent,-1,_("Select Fields to Paste Over"),wxDefaultPosition,wxDefaultSize)
|
: wxDialog (parent,-1,_("Select Fields to Paste Over"),wxDefaultPosition,wxDefaultSize)
|
||||||
|
, options(options)
|
||||||
{
|
{
|
||||||
// Script mode
|
// Script mode
|
||||||
int mode = 1; // ASS
|
int mode = 1; // ASS
|
||||||
|
@ -89,9 +95,8 @@ DialogPasteOver::DialogPasteOver (wxWindow *parent)
|
||||||
|
|
||||||
// Load checked items
|
// Load checked items
|
||||||
/// @todo This assumes a static set of fields.
|
/// @todo This assumes a static set of fields.
|
||||||
std::vector<bool> choice_array;
|
OPT_GET("Tool/Paste Lines Over/Fields")->GetListBool(options);
|
||||||
OPT_GET("Tool/Paste Lines Over/Fields")->GetListBool(choice_array);
|
for (unsigned int i=0;i<choices.Count();i++) ListBox->Check(i,options[i]);
|
||||||
for (unsigned int i=0;i<choices.Count();i++) ListBox->Check(i,choice_array.at(i));
|
|
||||||
|
|
||||||
// Top buttons
|
// Top buttons
|
||||||
wxSizer *TopButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *TopButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@ -117,16 +122,10 @@ DialogPasteOver::DialogPasteOver (wxWindow *parent)
|
||||||
Center();
|
Center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
///
|
|
||||||
DialogPasteOver::~DialogPasteOver() {
|
DialogPasteOver::~DialogPasteOver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
|
||||||
// Event table
|
|
||||||
BEGIN_EVENT_TABLE(DialogPasteOver, wxDialog)
|
BEGIN_EVENT_TABLE(DialogPasteOver, wxDialog)
|
||||||
EVT_BUTTON(wxID_OK,DialogPasteOver::OnOK)
|
EVT_BUTTON(wxID_OK,DialogPasteOver::OnOK)
|
||||||
EVT_BUTTON(wxID_CANCEL,DialogPasteOver::OnCancel)
|
EVT_BUTTON(wxID_CANCEL,DialogPasteOver::OnCancel)
|
||||||
|
@ -136,76 +135,40 @@ BEGIN_EVENT_TABLE(DialogPasteOver, wxDialog)
|
||||||
EVT_BUTTON(Paste_Over_Times,DialogPasteOver::OnTimes)
|
EVT_BUTTON(Paste_Over_Times,DialogPasteOver::OnTimes)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief OK pressed
|
/// @brief OK pressed
|
||||||
/// @param event
|
void DialogPasteOver::OnOK(wxCommandEvent &) {
|
||||||
///
|
|
||||||
void DialogPasteOver::OnOK(wxCommandEvent &event) {
|
|
||||||
|
|
||||||
std::vector<bool> map;
|
|
||||||
for (int i=0;i<10;i++) {
|
for (int i=0;i<10;i++) {
|
||||||
map[i] = ListBox->IsChecked(i);
|
options[i] = ListBox->IsChecked(i);
|
||||||
}
|
}
|
||||||
OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(map);
|
OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(options);
|
||||||
|
|
||||||
EndModal(1);
|
EndModal(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Cancel pressed
|
/// @brief Cancel pressed
|
||||||
/// @param event
|
void DialogPasteOver::OnCancel(wxCommandEvent &) {
|
||||||
///
|
|
||||||
void DialogPasteOver::OnCancel(wxCommandEvent &event) {
|
|
||||||
EndModal(0);
|
EndModal(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Select Text
|
/// @brief Select Text
|
||||||
/// @param event
|
void DialogPasteOver::OnText(wxCommandEvent &) {
|
||||||
///
|
|
||||||
void DialogPasteOver::OnText(wxCommandEvent &event) {
|
|
||||||
for (int i=0;i<9;i++) ListBox->Check(i,false);
|
for (int i=0;i<9;i++) ListBox->Check(i,false);
|
||||||
ListBox->Check(9,true);
|
ListBox->Check(9,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Select Times
|
/// @brief Select Times
|
||||||
/// @param event
|
void DialogPasteOver::OnTimes(wxCommandEvent &) {
|
||||||
///
|
|
||||||
void DialogPasteOver::OnTimes(wxCommandEvent &event) {
|
|
||||||
for (int i=0;i<10;i++) ListBox->Check(i,false);
|
for (int i=0;i<10;i++) ListBox->Check(i,false);
|
||||||
ListBox->Check(1,true);
|
ListBox->Check(1,true);
|
||||||
ListBox->Check(2,true);
|
ListBox->Check(2,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Select All
|
/// @brief Select All
|
||||||
/// @param event
|
void DialogPasteOver::OnAll(wxCommandEvent &) {
|
||||||
///
|
|
||||||
void DialogPasteOver::OnAll(wxCommandEvent &event) {
|
|
||||||
for (int i=0;i<10;i++) ListBox->Check(i,true);
|
for (int i=0;i<10;i++) ListBox->Check(i,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Select None
|
/// @brief Select None
|
||||||
/// @param event
|
void DialogPasteOver::OnNone(wxCommandEvent &) {
|
||||||
///
|
|
||||||
void DialogPasteOver::OnNone(wxCommandEvent &event) {
|
|
||||||
for (int i=0;i<10;i++) ListBox->Check(i,false);
|
for (int i=0;i<10;i++) ListBox->Check(i,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Get options
|
|
||||||
///
|
|
||||||
wxArrayInt DialogPasteOver::GetOptions() {
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,9 @@
|
||||||
/// @ingroup secondary_ui
|
/// @ingroup secondary_ui
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////
|
|
||||||
// Headers
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <wx/dialog.h>
|
#include <wx/dialog.h>
|
||||||
#include <wx/checklst.h>
|
#include <wx/checklst.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -57,7 +54,7 @@ private:
|
||||||
wxCheckListBox *ListBox;
|
wxCheckListBox *ListBox;
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
wxArrayInt options;
|
std::vector<bool>& options;
|
||||||
|
|
||||||
void OnOK(wxCommandEvent &event);
|
void OnOK(wxCommandEvent &event);
|
||||||
void OnCancel(wxCommandEvent &event);
|
void OnCancel(wxCommandEvent &event);
|
||||||
|
@ -67,30 +64,8 @@ private:
|
||||||
void OnNone(wxCommandEvent &event);
|
void OnNone(wxCommandEvent &event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogPasteOver(wxWindow *parent);
|
DialogPasteOver(wxWindow *parent, std::vector<bool>& options);
|
||||||
~DialogPasteOver();
|
~DialogPasteOver();
|
||||||
|
|
||||||
wxArrayInt GetOptions();
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///////
|
|
||||||
// IDs
|
|
||||||
enum {
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
Paste_Over_Times = 1620,
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
Paste_Over_Text,
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
Paste_Over_All,
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
Paste_Over_None
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1010,8 +1010,7 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
|
||||||
if (!data.empty()) {
|
if (!data.empty()) {
|
||||||
// Insert data
|
// Insert data
|
||||||
int inserted = 0;
|
int inserted = 0;
|
||||||
bool asked = false;
|
std::vector<bool> pasteOverOptions;
|
||||||
wxArrayInt pasteOverOptions;
|
|
||||||
wxStringTokenizer token (data,_T("\r\n"),wxTOKEN_STRTOK);
|
wxStringTokenizer token (data,_T("\r\n"),wxTOKEN_STRTOK);
|
||||||
while (token.HasMoreTokens()) {
|
while (token.HasMoreTokens()) {
|
||||||
// Convert data into an AssDialogue
|
// Convert data into an AssDialogue
|
||||||
|
@ -1037,14 +1036,12 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
|
||||||
if (pasteOver) {
|
if (pasteOver) {
|
||||||
if (n+inserted < GetRows()) {
|
if (n+inserted < GetRows()) {
|
||||||
// Get list of options to paste over, if not asked yet
|
// Get list of options to paste over, if not asked yet
|
||||||
if (asked == false) {
|
if (pasteOverOptions.empty()) {
|
||||||
asked = true;
|
DialogPasteOver diag(NULL, pasteOverOptions);
|
||||||
DialogPasteOver diag(NULL);
|
|
||||||
if (!diag.ShowModal()) {
|
if (!diag.ShowModal()) {
|
||||||
delete curdiag;
|
delete curdiag;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pasteOverOptions = diag.GetOptions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paste over
|
// Paste over
|
||||||
|
|
Loading…
Reference in a new issue