Win32 - Memory Watch - Recent File Menu - no longer crashes if it fails to open a recent file
This commit is contained in:
parent
acdab16c24
commit
7dc8c713f1
|
@ -1,4 +1,5 @@
|
|||
---version 2.0.4 yet to be released---
|
||||
19-feb-2009 - adelikat - win32 - memory watch - fixed recent file menu - no longer crashes when attempting to load a non existent recent file
|
||||
07-feb-2009 - adelikat - win32 - Fix bug in screenshot numbering that caused numbering to not reset when changing ROMs
|
||||
06-feb-2009 - adelikat - win32 - Hex editor - remembers window size
|
||||
06-feb-2009 - adelikat - Win32 - sound config dialog - added sliders for individual sound channel volume control
|
||||
|
|
|
@ -31,6 +31,15 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
//Memory Watch named constants-----------------------------------
|
||||
const int NUMWATCHES = 24; //Maximum Number of Watches
|
||||
const int LABELLENGTH = 64; //Maximum Length of a Watch label
|
||||
const int ADDRESSLENGTH = 16; //Maximum Length of a Ram Address
|
||||
|
||||
//Prototypes
|
||||
void RamChangeReset(int x); //Called when user hits reset button
|
||||
void CollapseWindow(void); //Called when user collapses or expands window
|
||||
|
||||
//Memory Watch GUI Handles & Globals---------------------------
|
||||
HWND hwndMemWatch=0; //Handle to Memwatch Window
|
||||
static HDC hdc; //Handle to to Device Context
|
||||
|
@ -38,12 +47,7 @@ static HMENU memwmenu = 0; //Handle to Memwatch Menu
|
|||
static HMENU memwrecentmenu;//Handle to Recent Files Menu
|
||||
|
||||
int MemWatch_wndx=0, MemWatch_wndy=0; //Window Position
|
||||
|
||||
bool MemWCollapsed = false; //Flag to determine if window is currently collapsed
|
||||
//Memory Watch globals-----------------------------------------
|
||||
const int NUMWATCHES = 24; //Maximum Number of Watches
|
||||
const int LABELLENGTH = 64; //Maximum Length of a Watch label
|
||||
const int ADDRESSLENGTH = 16; //Maximum Length of a Ram Address
|
||||
|
||||
static char addresses[NUMWATCHES][ADDRESSLENGTH]; //Stores all address labels
|
||||
static char labels[NUMWATCHES][LABELLENGTH]; //Stores all label lengths
|
||||
|
@ -72,9 +76,6 @@ int editnow[MAX_RAMMONITOR]; //current address value
|
|||
unsigned int editcount[MAX_RAMMONITOR]; //Current counter value
|
||||
char editchangem[MAX_RAMMONITOR][5]; //counter converted to string
|
||||
|
||||
//Prototypes
|
||||
void RamChangeReset(int x); //Called when user hits reset button
|
||||
void CollapseWindow(void); //Called when user collapses or expands window
|
||||
//-------------------------------------------------
|
||||
|
||||
void UpdateMemw_RMenu(HMENU menu, char **strs, unsigned int mitem, unsigned int baseid)
|
||||
|
@ -577,22 +578,21 @@ static void LoadMemWatch()
|
|||
fileChanged = false;
|
||||
}
|
||||
|
||||
// Loads a recent file given the recent files array number(0-4)
|
||||
//Loads a recent file given the recent files array number(0-4)
|
||||
void OpenMemwatchRecentFile(int memwRFileNumber)
|
||||
{
|
||||
int rnum=memwRFileNumber;
|
||||
if (rnum > MEMW_MAX_NUMBER_OF_RECENT_FILES) return; //just in case
|
||||
if (memwRFileNumber > MEMW_MAX_NUMBER_OF_RECENT_FILES) return; //just in case
|
||||
|
||||
char* x = memw_recent_files[rnum];
|
||||
char* x = memw_recent_files[memwRFileNumber];
|
||||
if (x == NULL) return; //If no recent files exist just return. Useful for Load last file on startup (or if something goes screwy)
|
||||
char watchfcontents[2048];
|
||||
|
||||
FILE *fp=FCEUD_UTF8fopen(x,"r");
|
||||
FILE *fp=FCEUD_UTF8fopen(x,"r"); //Open the recent file
|
||||
if (fp) //Check if file opening was successful, if not, abort
|
||||
{
|
||||
strcpy(memwLastFilename,x);
|
||||
|
||||
if (rnum != 0) //Change order of recent files if not most recent
|
||||
if (memwRFileNumber != 0) //Change order of recent files if not most recent
|
||||
MemwAddRecentFile(x);
|
||||
|
||||
int i,j;
|
||||
for(i=0;i<NUMWATCHES;i++)
|
||||
{
|
||||
|
@ -623,9 +623,12 @@ void OpenMemwatchRecentFile(int memwRFileNumber)
|
|||
SetDlgItemText(hwndMemWatch,MW_ADDR(i),(LPTSTR) addresses[i]);
|
||||
SetDlgItemText(hwndMemWatch,MW_NAME(i),(LPTSTR) labels[i]);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
fileChanged = false;
|
||||
fclose(fp); //Close the file
|
||||
fileChanged = false; //Flag that the memwatch file has not been changed since last save
|
||||
}
|
||||
else //Opening fp failed
|
||||
MessageBox(hwndMemWatch,"Error: Could not open recent file", "Memory Watch Recent File", MB_OK);
|
||||
//TODO: Remove this file from the recent list
|
||||
}
|
||||
|
||||
void CloseMemoryWatch()
|
||||
|
|
Loading…
Reference in New Issue