cppcheck and valgrind code hardening for Qt Tas editor.

This commit is contained in:
mjbudd77 2021-12-23 21:02:16 -05:00
parent ceaa04b0f4
commit 571caf3234
10 changed files with 68 additions and 51 deletions

View File

@ -277,6 +277,8 @@ TasEditorWindow::~TasEditorWindow(void)
::branches = NULL; ::branches = NULL;
::splicer = NULL; ::splicer = NULL;
clearProjectList();
fceuWrapperUnLock(); fceuWrapperUnLock();
// Save Horizontal Panel State // Save Horizontal Panel State

View File

@ -30,6 +30,7 @@ extern uint8 *XBackBuf;
BOOKMARK::BOOKMARK() BOOKMARK::BOOKMARK()
{ {
notEmpty = false; notEmpty = false;
flashType = flashPhase = floatingPhase = 0;
} }
void BOOKMARK::init() void BOOKMARK::init()

View File

@ -49,6 +49,8 @@ BOOKMARKS::BOOKMARKS(QWidget *parent)
viewWidth = 256; viewWidth = 256;
viewHeight = 256; viewHeight = 256;
editMode = EDIT_MODE_BOOKMARKS;
imageItem = 0; imageItem = 0;
imageTimer = new QTimer(this); imageTimer = new QTimer(this);
imageTimer->setSingleShot(true); imageTimer->setSingleShot(true);
@ -86,6 +88,7 @@ void BOOKMARKS::init()
reset(); reset();
selectedSlot = DEFAULT_SLOT; selectedSlot = DEFAULT_SLOT;
imageItem = 0; imageItem = 0;
editMode = EDIT_MODE_BOOKMARKS;
redrawBookmarksSectionCaption(); redrawBookmarksSectionCaption();
} }
@ -820,6 +823,7 @@ bool BOOKMARKS::event(QEvent *event)
{ {
if (event->type() == QEvent::ToolTip) if (event->type() == QEvent::ToolTip)
{ {
fceuCriticalSection emuLock;
int item, row_under_mouse, item_valid, column; int item, row_under_mouse, item_valid, column;
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);

View File

@ -43,6 +43,21 @@ BRANCHES::BRANCHES(QWidget *parent)
{ {
std::string fontString; std::string fontString;
mustRedrawBranchesBitmap = false;
mustRecalculateBranchesTree = false;
branchRightclicked = 0;
currentBranch = 0;
changesSinceCurrentBranch = false;
memset( cloudTimestamp, 0, sizeof(cloudTimestamp) );
memset( currentPosTimestamp, 0, sizeof(currentPosTimestamp) );
transitionPhase = 0;
currentAnimationFrame = 0;
nextAnimationTime = 0;
playbackCursorX = playbackCursorY = 0;
cornersCursorX = cornersCursorY = 0;
fireballSize = 0;
lastItemUnderMouse = -1;
imageItem = 0; imageItem = 0;
imageTimer = new QTimer(this); imageTimer = new QTimer(this);
imageTimer->setSingleShot(true); imageTimer->setSingleShot(true);
@ -127,7 +142,6 @@ void BRANCHES::init()
free(); free();
// subclass BranchesBitmap // subclass BranchesBitmap
//hwndBranchesBitmap_oldWndProc = (WNDPROC)SetWindowLongPtr(bookmarks.hwndBranchesBitmap, GWLP_WNDPROC, (LONG_PTR)BranchesBitmapWndProc);
// init arrays // init arrays
branchX.resize(TOTAL_BOOKMARKS+1); branchX.resize(TOTAL_BOOKMARKS+1);
@ -497,6 +511,7 @@ void BRANCHES::mouseDoubleClickEvent(QMouseEvent * event)
void BRANCHES::mousePressEvent(QMouseEvent * event) void BRANCHES::mousePressEvent(QMouseEvent * event)
{ {
fceuCriticalSection emuLock;
int item = findItemUnderMouse( event->pos().x(), event->pos().y() ); int item = findItemUnderMouse( event->pos().x(), event->pos().y() );
bookmarks->itemUnderMouse = item; bookmarks->itemUnderMouse = item;
@ -546,6 +561,7 @@ void BRANCHES::mousePressEvent(QMouseEvent * event)
void BRANCHES::mouseReleaseEvent(QMouseEvent * event) void BRANCHES::mouseReleaseEvent(QMouseEvent * event)
{ {
fceuCriticalSection emuLock;
int item = findItemUnderMouse( event->pos().x(), event->pos().y() ); int item = findItemUnderMouse( event->pos().x(), event->pos().y() );
bookmarks->itemUnderMouse = item; bookmarks->itemUnderMouse = item;
@ -573,6 +589,7 @@ void BRANCHES::showImage(void)
void BRANCHES::mouseMoveEvent(QMouseEvent * event) void BRANCHES::mouseMoveEvent(QMouseEvent * event)
{ {
fceuCriticalSection emuLock;
int item, item_valid; int item, item_valid;
item = findItemUnderMouse( event->pos().x(), event->pos().y() ); item = findItemUnderMouse( event->pos().x(), event->pos().y() );
@ -608,6 +625,7 @@ bool BRANCHES::event(QEvent *event)
{ {
if (event->type() == QEvent::ToolTip) if (event->type() == QEvent::ToolTip)
{ {
fceuCriticalSection emuLock;
int item, item_valid; int item, item_valid;
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
@ -671,7 +689,8 @@ void BRANCHES::paintEvent(QPaintEvent *event)
{ {
parentX = branchCurrentX[t-1]; parentX = branchCurrentX[t-1];
parentY = branchCurrentY[t-1]; parentY = branchCurrentY[t-1];
} else }
else
{ {
parentX = cloudCurrentX; parentX = cloudCurrentX;
parentY = BRANCHES_CLOUD_Y; parentY = BRANCHES_CLOUD_Y;
@ -679,7 +698,7 @@ void BRANCHES::paintEvent(QPaintEvent *event)
for (int i = children[t].size() - 1; i >= 0; i--) for (int i = children[t].size() - 1; i >= 0; i--)
{ {
childID = children[t][i]; childID = children[t][i];
if (childID < TOTAL_BOOKMARKS) if ( (childID >= 0) && (childID < TOTAL_BOOKMARKS) )
{ {
//MoveToEx(hBitmapDC, parentX, parentY, 0); //MoveToEx(hBitmapDC, parentX, parentY, 0);
//LineTo(hBitmapDC, branchCurrentX[childID], branchCurrentY[childID]); //LineTo(hBitmapDC, branchCurrentX[childID], branchCurrentY[childID]);

View File

@ -28,19 +28,10 @@ Greenzone - Access zone
#include "Qt/TasEditor/taseditor_project.h" #include "Qt/TasEditor/taseditor_project.h"
#include "Qt/TasEditor/TasEditorWindow.h" #include "Qt/TasEditor/TasEditorWindow.h"
//extern TASEDITOR_CONFIG taseditorConfig;
//extern TASEDITOR_PROJECT project;
//extern PLAYBACK playback;
//extern HISTORY history;
//extern BOOKMARKS bookmarks;
//extern MARKERS_MANAGER markersManager;
//extern PIANO_ROLL pianoRoll;
//extern SELECTION selection;
extern char lagFlag; extern char lagFlag;
char greenzone_save_id[GREENZONE_ID_LEN] = "GREENZONE"; static char greenzone_save_id[GREENZONE_ID_LEN] = "GREENZONE";
char greenzone_skipsave_id[GREENZONE_ID_LEN] = "GREENZONX"; static char greenzone_skipsave_id[GREENZONE_ID_LEN] = "GREENZONX";
GREENZONE::GREENZONE() GREENZONE::GREENZONE()
{ {
@ -224,13 +215,15 @@ void GREENZONE::ungreenzoneSelectedFrames()
RowsSelection* current_selection = selection->getCopyOfCurrentRowsSelection(); RowsSelection* current_selection = selection->getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return; if (current_selection->size() == 0) return;
bool changed = false; bool changed = false;
int size = savestates.size(); //int size = savestates.size();
int start_index = *current_selection->begin(); //int start_index = *current_selection->begin();
int end_index = *current_selection->rbegin(); //int end_index = *current_selection->rbegin();
RowsSelection::reverse_iterator current_selection_rend = current_selection->rend(); RowsSelection::reverse_iterator current_selection_rend = current_selection->rend();
// degreenzone frames, going backwards // degreenzone frames, going backwards
for (RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++) for (RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
{
changed = changed | clearSavestateAndFreeMemory(*it); changed = changed | clearSavestateAndFreeMemory(*it);
}
if (changed) if (changed)
{ {
//pianoRoll.redraw(); //pianoRoll.redraw();

View File

@ -30,6 +30,10 @@ int joysticksPerFrame[INPUT_TYPES_TOTAL] = {1, 2, 4};
INPUTLOG::INPUTLOG() INPUTLOG::INPUTLOG()
{ {
size = 0;
inputType = 0;
hasHotChanges = 0;
alreadyCompressed = false;
} }
void INPUTLOG::init(MovieData& md, bool hotchanges, int force_input_type) void INPUTLOG::init(MovieData& md, bool hotchanges, int force_input_type)

View File

@ -28,40 +28,30 @@ Selection - Manager of selections
#include "Qt/TasEditor/taseditor_project.h" #include "Qt/TasEditor/taseditor_project.h"
#include "Qt/TasEditor/TasEditorWindow.h" #include "Qt/TasEditor/TasEditorWindow.h"
//extern TASEDITOR_CONFIG taseditorConfig;
//extern TASEDITOR_WINDOW taseditorWindow;
//extern MARKERS_MANAGER markersManager;
//extern PIANO_ROLL pianoRoll;
//extern SPLICER splicer;
//extern EDITOR editor;
//extern GREENZONE greenzone;
extern int joysticksPerFrame[INPUT_TYPES_TOTAL]; extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
//LRESULT APIENTRY LowerMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
//WNDPROC selectionMarkerEdit_oldWndproc;
// resources // resources
char selection_save_id[SELECTION_ID_LEN] = "SELECTION"; static char selection_save_id[SELECTION_ID_LEN] = "SELECTION";
char selection_skipsave_id[SELECTION_ID_LEN] = "SELECTIOX"; static char selection_skipsave_id[SELECTION_ID_LEN] = "SELECTIOX";
char lowerMarkerText[] = "Marker "; static char lowerMarkerText[] = "Marker ";
SELECTION::SELECTION() SELECTION::SELECTION()
{ {
trackSelectionChanges = true;
lastSelectionBeginning = -1;
previousMarkerButtonState = previousMarkerButtonOldState = false;
nextMarkerButtonState = nextMarkerButtonOldState = false;
buttonHoldTimer = 0;
historyCursorPos = -1;
historyStartPos = 0;
historySize = 1;
historyTotalItems = 0;
} }
void SELECTION::init() void SELECTION::init()
{ {
//hwndPreviousMarkerButton = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_PREV_MARKER);
//hwndNextMarkerButton = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_NEXT_MARKER);
//hwndSelectionMarkerNumber = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_SELECTION_MARKER);
//SendMessage(hwndSelectionMarkerNumber, WM_SETFONT, (WPARAM)pianoRoll.hMarkersFont, 0);
//hwndSelectionMarkerEditField = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_SELECTION_MARKER_EDIT);
//SendMessage(hwndSelectionMarkerEditField, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
//SendMessage(hwndSelectionMarkerEditField, WM_SETFONT, (WPARAM)pianoRoll.hMarkersEditFont, 0);
// subclass the edit control
//selectionMarkerEdit_oldWndproc = (WNDPROC)SetWindowLongPtr(hwndSelectionMarkerEditField, GWLP_WNDPROC, (LONG_PTR)LowerMarkerEditWndProc);
reset(); reset();
} }
void SELECTION::free() void SELECTION::free()
@ -396,7 +386,7 @@ bool SELECTION::skipLoadSelection(EMUFILE *is)
void SELECTION::noteThatItemRangeChanged(int startItem, int endItem, int newValue ) void SELECTION::noteThatItemRangeChanged(int startItem, int endItem, int newValue )
{ {
bool ON = newValue; bool ON = newValue;
bool OFF = !newValue; //bool OFF = !newValue;
if (ON) if (ON)
{ {

View File

@ -20,14 +20,17 @@ Snapshot - Snapshot of all edited data
#include "Qt/TasEditor/taseditor_project.h" #include "Qt/TasEditor/taseditor_project.h"
#include "Qt/TasEditor/TasEditorWindow.h" #include "Qt/TasEditor/TasEditorWindow.h"
//extern MARKERS_MANAGER markersManager;
//extern SELECTION selection;
//extern GREENZONE greenzone;
extern int getInputType(MovieData& md); extern int getInputType(MovieData& md);
SNAPSHOT::SNAPSHOT() SNAPSHOT::SNAPSHOT()
{ {
keyFrame = 0;
startFrame = 0;
endFrame = 0;
consecutivenessTag = 0;
recordedJoypadDifferenceBits = 0;
modificationType = 0;
description[0] = 0;
} }
void SNAPSHOT::init(MovieData& md, LAGLOG& lagLog, bool hotchanges, int enforceInputType) void SNAPSHOT::init(MovieData& md, LAGLOG& lagLog, bool hotchanges, int enforceInputType)

View File

@ -37,13 +37,13 @@ extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
// resources // resources
static char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"}; static char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"};
static char selectionText[] = "Selection: "; //static char selectionText[] = "Selection: ";
static char selectionEmptyText[] = "no"; static char selectionEmptyText[] = "no";
static char numTextRow[] = "1 row, "; static char numTextRow[] = "1 row, ";
static char numTextRows[] = " rows, "; static char numTextRows[] = " rows, ";
static char numTextColumn[] = "1 column"; static char numTextColumn[] = "1 column";
static char numTextColumns[] = " columns"; static char numTextColumns[] = " columns";
static char clipboardText[] = "Clipboard: "; //static char clipboardText[] = "Clipboard: ";
static char clipboardEmptyText[] = "empty"; static char clipboardEmptyText[] = "empty";
SPLICER::SPLICER() SPLICER::SPLICER()
@ -307,7 +307,7 @@ void SPLICER::deleteSelectedFrames(void)
bool markers_changed = false; bool markers_changed = false;
int start_index = *current_selection->begin(); int start_index = *current_selection->begin();
int end_index = *current_selection->rbegin(); //int end_index = *current_selection->rbegin();
RowsSelection::reverse_iterator current_selection_rend = current_selection->rend(); RowsSelection::reverse_iterator current_selection_rend = current_selection->rend();
// delete frames on each selection, going backwards // delete frames on each selection, going backwards
for(RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++) for(RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
@ -476,7 +476,7 @@ bool SPLICER::copySelectedInputToClipboard(RowsSelection* currentSelectionOverri
//CloseClipboard(); //CloseClipboard();
} }
catch (std::bad_alloc e) catch (std::bad_alloc const &e)
{ {
return false; return false;
} }
@ -648,7 +648,7 @@ bool SPLICER::pasteInsertInputFromClipboard(void)
pGlobal = strchr(pGlobal, '\n'); pGlobal = strchr(pGlobal, '\n');
const char* frame; const char* frame;
int joy=0; //int joy=0;
std::vector<uint8> flash_joy(num_joypads); std::vector<uint8> flash_joy(num_joypads);
pos--; pos--;
while (pGlobal++ && *pGlobal!='\0') while (pGlobal++ && *pGlobal!='\0')

View File

@ -85,6 +85,7 @@ gwavi_t::gwavi_t(void)
avi_std = 2; avi_std = 2;
audioEnabled = false; audioEnabled = false;
riffWalkCallback = NULL; riffWalkCallback = NULL;
riffWalkUserData = NULL;
readBuf = NULL; readBuf = NULL;
readBufSize = 0; readBufSize = 0;
} }