Browse Source

fixed: ttcalc didn't correctly delete variables/functions from its config file

so when you restarted the program you still had the deleted variables/functions



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@347 e52654a7-88a9-db11-a3e9-0013d4bc506e
master
Tomasz Sowa 11 years ago
parent
commit
547f01bf34
  1. 2
      CHANGELOG
  2. 8
      src/functions.cpp
  3. 26
      src/resource.rc
  4. 8
      src/variables.cpp
  5. 2
      src/winmain.cpp

2
CHANGELOG

@ -8,6 +8,8 @@ Version 0.9.3 prerelease (2011.05.29):
to copy them to the clipboard, then press a button let we say
"sin" - the result is: "sin(123+34)+56"
* updated: Chinese translation
* fixed: ttcalc didn't correctly delete variables/functions from its config file
so when you restarted the program you still had the deleted variables/functions
Version 0.9.2 (2010.09.24):

8
src/functions.cpp

@ -237,6 +237,8 @@ BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam)
{
int id = AddNewItemToFunctionList(list, name, value, parameters);
Variables::SelectOnlyOneItem(list,id);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
@ -302,7 +304,11 @@ adding = false;
if( code != ttmath::err_ok )
ShowError(list, code);
else
{
ChangeItemInFunctionList(list, id, old_name, name, value, parameters);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
while( code != ttmath::err_ok );
@ -335,6 +341,7 @@ int items = ListView_GetSelectedCount(list);
char * buffer = new char[buffer_size];
bool all_deleted = true;
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->GetThreadController()->StopCalculating();
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
@ -353,6 +360,7 @@ int items = ListView_GetSelectedCount(list);
GetPrgRes()->GetThreadController()->StartCalculating();
GetPrgRes()->SaveToFile();
delete [] buffer;

26
src/resource.rc

@ -93,7 +93,7 @@ BEGIN
END
101 DIALOGEX 0, 0, 295, 189
IDD_MAIN_DIALOG DIALOGEX 0, 0, 295, 189
STYLE DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU | WS_THICKFRAME
CAPTION "TTCalc"
@ -107,7 +107,7 @@ BEGIN
END
102 DIALOG DISCARDABLE 0, 0, 358, 61
IDD_DIALOG_ADD_VARIABLE DIALOG DISCARDABLE 0, 0, 358, 61
STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "Add a new variable"
@ -121,7 +121,7 @@ BEGIN
LTEXT "value:",IDC_STATIC_VARIABLE_VALUE,7,30,38,8
END
103 DIALOG DISCARDABLE 0, 0, 370, 74
IDD_DIALOG_ADD_FUNCTION DIALOG DISCARDABLE 0, 0, 370, 74
STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
FONT 8, "Ms Shell Dlg"
@ -137,7 +137,7 @@ BEGIN
END
110 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_STANDARD DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_GROUP | WS_TABSTOP
FONT 8, "Ms Shell Dlg"
BEGIN
@ -196,7 +196,7 @@ BEGIN
END
111 DIALOG 0, 0, 288, 107
IDD_DIALOG_VARIABLES DIALOG 0, 0, 288, 107
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab2"
FONT 8, "Ms Shell Dlg"
@ -207,7 +207,7 @@ BEGIN
CONTROL "",IDC_VARIABLES_LIST,"SysListView32",LVS_REPORT |LVS_SHOWSELALWAYS |LVS_SORTASCENDING |LVS_ALIGNLEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,57,3,223,85
END
112 DIALOG 0, 0, 288, 107
IDD_DIALOG_FUNCTIONS DIALOG 0, 0, 288, 107
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab3"
FONT 8, "Ms Shell Dlg"
@ -220,7 +220,7 @@ END
#ifndef TTCALC_PORTABLE
113 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_PRECISION DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
WS_TABSTOP
CAPTION "tab4"
@ -244,7 +244,7 @@ END
#endif
114 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_DISPLAY DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
WS_TABSTOP
CAPTION "tab5"
@ -304,7 +304,7 @@ END
#ifdef TTCALC_CONVERT
115 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_CONVERT DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
WS_TABSTOP
CAPTION "tab6"
@ -337,7 +337,7 @@ END
#endif
#ifndef TTCALC_PORTABLE
200 DIALOG DISCARDABLE 0, 0, 349, 284
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 349, 284
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "About"
@ -349,15 +349,15 @@ BEGIN
DEFPUSHBUTTON "Close",IDOK,191,259,86,14
END
#else
200 DIALOG DISCARDABLE 0, 0, 268, 322
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 268, 362
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_ABOUT_TEXT,16,18,234,269,ES_MULTILINE | ES_READONLY |
EDITTEXT IDC_ABOUT_TEXT,16,18,234,315,ES_MULTILINE | ES_READONLY |
NOT WS_BORDER | NOT WS_TABSTOP
DEFPUSHBUTTON "Close",IDOK,90,292,86,14
DEFPUSHBUTTON "Close",IDOK,90,339,86,14
END
#endif

8
src/variables.cpp

@ -268,6 +268,8 @@ BOOL WmTabCommand_AddVariable(HWND, UINT message, WPARAM wParam, LPARAM lParam)
{
int id = AddNewItemToVariableList(list, name, value);
SelectOnlyOneItem(list,id);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
while( code != ttmath::err_ok );
@ -329,7 +331,11 @@ adding = false;
if( code != ttmath::err_ok )
ShowError(list, code);
else
{
ChangeItemInVariableList(list, id, old_name, name, value);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
while( code != ttmath::err_ok );
@ -362,6 +368,7 @@ int items = ListView_GetSelectedCount(list);
char * buffer = new char[buffer_size];
bool all_deleted = true;
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->GetThreadController()->StopCalculating();
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
@ -380,6 +387,7 @@ int items = ListView_GetSelectedCount(list);
GetPrgRes()->GetThreadController()->StartCalculating();
GetPrgRes()->SaveToFile();
delete [] buffer;

2
src/winmain.cpp

@ -116,8 +116,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR par, int)
// there can be another variables/functions saved by other instantion of TTCalc
// we're reading them now
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
DestroyPadWindow();
CloseHandle( (HANDLE)thread_handle );

Loading…
Cancel
Save