Skip to content

Commit

Permalink
message exit code fix & better checking
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Mar 23, 2016
1 parent 277a008 commit b4cb23e
Show file tree
Hide file tree
Showing 24 changed files with 101 additions and 86 deletions.
6 changes: 5 additions & 1 deletion far/changelog
@@ -1,4 +1,8 @@
w17 23.03.2016 17:59:00 +0300 - build 4591
drkns 23.03.2016 20:31:08 +0200 - build 4592

1. С форума: Не логичное поведение при удалении сетевого диска

w17 23.03.2016 17:59:00 +0300 - build 4591

1. M#3089: Мелкая правка в панели информации (Ctrl+L)

Expand Down
8 changes: 4 additions & 4 deletions far/config.cpp
Expand Up @@ -460,7 +460,7 @@ void Options::MaskGroupsSettings()
{
case KEY_NUMDEL:
case KEY_DEL:
if(Item && !Message(0,2,MSG(MMenuMaskGroups),MSG(MMaskGroupAskDelete), Item->data(), MSG(MDelete), MSG(MCancel)))
if(Item && Message(0,2,MSG(MMenuMaskGroups),MSG(MMaskGroupAskDelete), Item->data(), MSG(MDelete), MSG(MCancel)) == Message::first_button)
{
ConfigProvider().GeneralCfg()->DeleteValue(L"Masks", *Item);
Changed = true;
Expand Down Expand Up @@ -505,10 +505,10 @@ void Options::MaskGroupsSettings()
case KEY_CTRLR:
case KEY_RCTRLR:
{
if (!Message(MSG_WARNING, 2,
if (Message(MSG_WARNING, 2,
MSG(MMenuMaskGroups),
MSG(MMaskGroupRestore),
MSG(MYes),MSG(MCancel)))
MSG(MYes),MSG(MCancel)) == Message::first_button)
{
ApplyDefaultMaskGroups();
Changed = true;
Expand Down Expand Up @@ -2080,7 +2080,7 @@ void Options::Save(bool Manual)
{
InitConfig();

if (Manual && Message(0,2,MSG(MSaveSetupTitle),MSG(MSaveSetupAsk1),MSG(MSaveSetupAsk2),MSG(MSaveSetup),MSG(MCancel)))
if (Manual && Message(0,2,MSG(MSaveSetupTitle),MSG(MSaveSetupAsk1),MSG(MSaveSetupAsk2),MSG(MSaveSetup),MSG(MCancel)) != Message::first_button)
return;

/* <ПРЕПРОЦЕССЫ> *************************************************** */
Expand Down
2 changes: 1 addition & 1 deletion far/configdb.cpp
Expand Up @@ -2503,7 +2503,7 @@ int config_provider::ShowProblems()
rc = Message(MSG_WARNING, MSG(MProblemDb),
m_Problems,
make_vector<string>(MSG(MShowConfigFolders), MSG(MIgnore))
) == 0 ? +1 : -1;
) == Message::first_button ? +1 : -1;
}
return rc;
}
Expand Down
6 changes: 3 additions & 3 deletions far/copy.cpp
Expand Up @@ -1908,7 +1908,7 @@ COPY_CODES ShellCopy::CopyFileTree(const string& Dest)
CP->SetNames(strSelName,strDestPath);

if (Message(MSG_WARNING,2,MSG(MError),MSG(MCopyCannotFind),
strSelName.data(),MSG(MSkip),MSG(MCancel))==1)
strSelName.data(),MSG(MSkip),MSG(MCancel)) == Message::second_button)
{
return COPY_FAILURE;
}
Expand Down Expand Up @@ -3368,8 +3368,8 @@ int ShellCopy::ShellCopyFile(const string& SrcName,const os::FAR_FIND_DATA &SrcD
else
{
if (!SplitCancelled && !SplitSkipped &&
!Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MError),
MSG(MCopyWriteError),strDestName.data(),MSG(MRetry),MSG(MCancel)))
Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MError),
MSG(MCopyWriteError),strDestName.data(),MSG(MRetry),MSG(MCancel)) == Message::first_button)
{
continue;
}
Expand Down
6 changes: 2 additions & 4 deletions far/datetime.hpp
Expand Up @@ -49,16 +49,14 @@ string MkStrFTime(const wchar_t* Format = nullptr);

inline uint64_t FileTimeToUI64(const FILETIME& ft)
{
ULARGE_INTEGER t = {ft.dwLowDateTime, ft.dwHighDateTime};
return t.QuadPart;
return ULARGE_INTEGER {ft.dwLowDateTime, ft.dwHighDateTime}.QuadPart;
}

inline FILETIME UI64ToFileTime(uint64_t time)
{
ULARGE_INTEGER i;
i.QuadPart = time;
FILETIME ft = { i.LowPart, i.HighPart };
return ft;
return FILETIME { i.LowPart, i.HighPart };
}

inline int CompareFileTime(const FILETIME& a, const FILETIME& b)
Expand Down
2 changes: 1 addition & 1 deletion far/delete.cpp
Expand Up @@ -1058,7 +1058,7 @@ bool ShellDelete::RemoveToRecycleBin(const string& Name, bool dir, DEL_RESULT& r
),
make_vector<string>(MSG(MYes), MSG(MCancel)),
nullptr, nullptr, &RecycleFolderConfirmDeleteLinkId
) != 0)
) != Message::first_button)
{
ret = DELETE_CANCEL;
return false;
Expand Down
2 changes: 1 addition & 1 deletion far/dirmix.cpp
Expand Up @@ -192,7 +192,7 @@ bool CheckShortcutFolder(string& pTestPath, bool TryClosest, bool Silent)
}
else // попытка найти!
{
if (Silent || !Message(MSG_WARNING | MSG_ERRORTYPE, 2, MSG(MError), strTarget.data(), MSG(MNeedNearPath), MSG(MHYes),MSG(MHNo)))
if (Silent || Message(MSG_WARNING | MSG_ERRORTYPE, 2, MSG(MError), strTarget.data(), MSG(MNeedNearPath), MSG(MHYes),MSG(MHNo)) == Message::first_button)
{
string strTestPathTemp = pTestPath;
for (;;)
Expand Down
10 changes: 5 additions & 5 deletions far/diskmenu.cpp
Expand Up @@ -355,7 +355,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType)
if (Message(MSG_WARNING, MSG(MChangeSUBSTDisconnectDriveTitle),
make_vector<string>(Question, MappedTo, SubstitutedPath),
make_vector<string>(MSG(MYes), MSG(MNo)),
nullptr, nullptr, &SUBSTDisconnectDriveId))
nullptr, nullptr, &SUBSTDisconnectDriveId) != Message::first_button)
{
return DRIVE_DEL_FAIL;
}
Expand All @@ -374,7 +374,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType)
if (Message(MSG_WARNING | MSG_ERRORTYPE, MSG(MError),
make_vector<string>(strMsgText, L"\x1", MSG(MChangeDriveOpenFiles), MSG(MChangeDriveAskDisconnect)),
make_vector<string>(MSG(MOk), MSG(MCancel)),
nullptr, nullptr, &SUBSTDisconnectDriveError1Id))
nullptr, nullptr, &SUBSTDisconnectDriveError1Id) == Message::first_button)
{
if (DelSubstDrive(DiskLetter))
{
Expand Down Expand Up @@ -424,7 +424,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType)
if (Message(MSG_WARNING | MSG_ERRORTYPE, MSG(MError),
make_vector<string>(strMsgText, L"\x1", MSG(MChangeDriveOpenFiles), MSG(MChangeDriveAskDisconnect)),
make_vector<string>(MSG(MOk), MSG(MCancel)),
nullptr, nullptr, &RemoteDisconnectDriveError1Id))
nullptr, nullptr, &RemoteDisconnectDriveError1Id) == Message::first_button)
{
if (WNetCancelConnection2(DiskLetter.data(), UpdateProfile, TRUE) == NO_ERROR)
{
Expand Down Expand Up @@ -458,7 +458,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType)
if (Message(MSG_WARNING, MSG(MChangeVHDDisconnectDriveTitle),
make_vector<string>(Question),
make_vector<string>(MSG(MYes), MSG(MNo)),
nullptr, nullptr, &VHDDisconnectDriveId))
nullptr, nullptr, &VHDDisconnectDriveId) != Message::first_button)
{
return DRIVE_DEL_FAIL;
}
Expand Down Expand Up @@ -587,7 +587,7 @@ static void RemoveHotplugDevice(panel_ptr Owner, const PanelMenuItem *item, VMen
MSG(MError),
make_vector<string>(string_format(MChangeCouldNotEjectHotPlugMedia, item->cDrive)),
make_vector<string>(MSG(MHRetry), MSG(MHCancel)),
nullptr, nullptr, &EjectHotPlugMediaErrorId);
nullptr, nullptr, &EjectHotPlugMediaErrorId) != Message::first_button;
}
else
DoneEject = TRUE;
Expand Down
22 changes: 11 additions & 11 deletions far/fileedit.cpp
Expand Up @@ -599,7 +599,7 @@ void FileEditor::Init(
if (Message(MSG_WARNING, MSG(MEditTitle),
make_vector<string>(Name, MSG(MEditRSH), MSG(MEditROOpen)),
make_vector<string>(MSG(MYes), MSG(MNo)),
nullptr, nullptr, &EditorOpenRSHId))
nullptr, nullptr, &EditorOpenRSHId) != Message::first_button)
{
SetExitCode(XC_OPEN_ERROR);
return;
Expand Down Expand Up @@ -1388,13 +1388,13 @@ int FileEditor::SetCodePage(uintptr_t cp, bool redetect_default, bool ascii2def)
{
if (IsFileModified())
{
int res = Message(
if (Message(
MSG_WARNING, 2, MSG(MEditTitle),
MSG(MEditorReloadCPWarnLost1), MSG(MEditorReloadCPWarnLost2),
MSG(MOk), MSG(MCancel));

if (res != 0)
MSG(MOk), MSG(MCancel)) != Message::first_button)
{
return EC_CP_NOTRELOAD_MODIFIED;
}
}
ReloadFile(cp);
}
Expand Down Expand Up @@ -1516,7 +1516,7 @@ int FileEditor::LoadFile(const string& Name,int &UserBreak)
string_format(MEditFileLong2, RemoveExternalSpaces(strTempStr2)),
MSG(MEditROOpen)),
make_vector<string>(MSG(MYes), MSG(MNo)),
nullptr, nullptr, &EditorFileLongId))
nullptr, nullptr, &EditorFileLongId) != Message::first_button)
{
EditFile.Close();
SetLastError(ERROR_OPEN_FAILED); //????
Expand All @@ -1532,7 +1532,7 @@ int FileEditor::LoadFile(const string& Name,int &UserBreak)
if (Message(MSG_WARNING, MSG(MEditTitle),
make_vector<string>(Name, MSG(MEditFileGetSizeError), MSG(MEditROOpen)),
make_vector<string>(MSG(MYes), MSG(MNo)),
nullptr, nullptr, &EditorFileGetSizeErrorId))
nullptr, nullptr, &EditorFileGetSizeErrorId) != Message::first_button)
{
EditFile.Close();
SetLastError(ERROR_OPEN_FAILED); //????
Expand Down Expand Up @@ -1860,13 +1860,13 @@ int FileEditor::SaveFile(const string& Name,int Ask, bool bSaveAs, int TextForma

if (BadConversion)
{
if(Message(MSG_WARNING,2,MSG(MWarning),MSG(MEditDataLostWarn),MSG(MEditorSaveNotRecommended),MSG(MEditorSave),MSG(MCancel)))
if(Message(MSG_WARNING,2,MSG(MWarning),MSG(MEditDataLostWarn),MSG(MEditorSaveNotRecommended),MSG(MEditorSave),MSG(MCancel)) == Message::first_button)
{
return SAVEFILE_CANCEL;
BadConversion = false;
}
else
{
BadConversion = false;
return SAVEFILE_CANCEL;
}
}

Expand Down Expand Up @@ -2873,7 +2873,7 @@ bool FileEditor::AskOverwrite(const string& FileName)
if (Message(MSG_WARNING, MSG(MEditTitle),
make_vector<string>(FileName, MSG(MEditExists), MSG(MEditOvr)),
make_vector<string>(MSG(MYes), MSG(MNo)),
nullptr, nullptr, &EditorAskOverwriteId))
nullptr, nullptr, &EditorAskOverwriteId) != Message::first_button)
{
result=false;
}
Expand Down
4 changes: 2 additions & 2 deletions far/filefilter.cpp
Expand Up @@ -348,8 +348,8 @@ bool FileFilter::FilterEdit()
string strQuotedTitle = FilterData()[SelPos].GetTitle();
InsertQuote(strQuotedTitle);

if (!Message(0,2,MSG(MFilterTitle),MSG(MAskDeleteFilter),
strQuotedTitle.data(),MSG(MDelete),MSG(MCancel)))
if (Message(0,2,MSG(MFilterTitle),MSG(MAskDeleteFilter),
strQuotedTitle.data(),MSG(MDelete),MSG(MCancel)) == Message::first_button)
{
FilterData().erase(FilterData().begin() + SelPos);
FilterList->DeleteItem(SelPos);
Expand Down
4 changes: 2 additions & 2 deletions far/filelist.cpp
Expand Up @@ -1685,7 +1685,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
if (Message(MSG_WARNING, MSG(MWarning),
make_vector<string>(MSG(MEditNewPath1), MSG(MEditNewPath2), MSG(MEditNewPath3)),
make_vector<string>(MSG(MHYes), MSG(MHNo)),
L"WarnEditorPath") != 0)
L"WarnEditorPath") != Message::first_button)
return FALSE;
}
}
Expand All @@ -1696,7 +1696,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
if (Message(MSG_WARNING, MSG(MWarning),
make_vector<string>(MSG(MEditNewPlugin1), MSG(MEditNewPath3)),
make_vector<string>(MSG(MCancel)),
L"WarnEditorPluginName") != 0)
L"WarnEditorPluginName") != Message::first_button)
return FALSE;
}
else
Expand Down
2 changes: 1 addition & 1 deletion far/filetype.cpp
Expand Up @@ -512,7 +512,7 @@ bool DeleteTypeRecord(unsigned __int64 DeletePos)
ConfigProvider().AssocConfig()->GetMask(DeletePos,strMask);
InsertQuote(strMask);

if (!Message(MSG_WARNING,2,MSG(MAssocTitle),MSG(MAskDelAssoc),strMask.data(),MSG(MDelete),MSG(MCancel)))
if (Message(MSG_WARNING,2,MSG(MAssocTitle),MSG(MAskDelAssoc),strMask.data(),MSG(MDelete),MSG(MCancel)) == Message::first_button)
{
ConfigProvider().AssocConfig()->DelType(DeletePos);
return true;
Expand Down
4 changes: 2 additions & 2 deletions far/hilight.cpp
Expand Up @@ -629,7 +629,7 @@ void HighlightFiles::HiEdit(int MenuPos)

if (Message(MSG_WARNING,2,MSG(MHighlightTitle),
MSG(MHighlightWarning),MSG(MHighlightAskRestore),
MSG(MYes),MSG(MCancel)) != 0)
MSG(MYes),MSG(MCancel)) != Message::first_button)
break;

const auto cfg = ConfigProvider().CreateHighlightConfig();
Expand All @@ -650,7 +650,7 @@ void HighlightFiles::HiEdit(int MenuPos)
{
if (Message(MSG_WARNING,2,MSG(MHighlightTitle),
MSG(MHighlightAskDel), HiData[RealSelectPos].GetMask().data(),
MSG(MDelete),MSG(MCancel)) != 0)
MSG(MDelete),MSG(MCancel)) != Message::first_button)
break;
HiData.erase(HiData.begin()+RealSelectPos);
(*Count)--;
Expand Down
6 changes: 3 additions & 3 deletions far/history.cpp
Expand Up @@ -457,11 +457,11 @@ history_return_type History::ProcessMenu(string &strStr, GUID* Guid, string *pst
if (!HistoryMenu.empty() &&
(!Global->Opt->Confirm.HistoryClear ||
(Global->Opt->Confirm.HistoryClear &&
!Message(MSG_WARNING,2,
Message(MSG_WARNING,2,
MSG((m_TypeHistory==HISTORYTYPE_CMD || m_TypeHistory==HISTORYTYPE_DIALOG?MHistoryTitle:
(m_TypeHistory==HISTORYTYPE_FOLDER?MFolderHistoryTitle:MViewHistoryTitle))),
MSG(MHistoryClear),
MSG(MClear),MSG(MCancel)))))
MSG(MClear),MSG(MCancel)) == Message::first_button)))
{
HistoryCfgRef()->DeleteAllUnlocked(m_TypeHistory,m_HistoryName);

Expand Down Expand Up @@ -502,7 +502,7 @@ history_return_type History::ProcessMenu(string &strStr, GUID* Guid, string *pst

if (SelectedRecordType == HR_EDITOR && m_TypeHistory == HISTORYTYPE_VIEW) // Edit? тогда спросим и если надо создадим
{
if (!Message(MSG_WARNING|MSG_ERRORTYPE,2,Title,strSelectedRecordName.data(),MSG(MViewHistoryIsCreate),MSG(MHYes),MSG(MHNo)))
if (Message(MSG_WARNING|MSG_ERRORTYPE,2,Title,strSelectedRecordName.data(),MSG(MViewHistoryIsCreate),MSG(MHYes),MSG(MHNo)) == Message::first_button)
break;
}
else
Expand Down
2 changes: 1 addition & 1 deletion far/language.cpp
Expand Up @@ -474,7 +474,7 @@ bool Language::CheckMsgId(LNGID MsgId) const
L"Error",
strMsg1.data(),
(L"Message " + std::to_wstring(MsgId) + L" not found").data(),
L"Ok", L"Quit")==1)
L"Ok", L"Quit") == Message::second_button)
exit(0);
}

Expand Down
4 changes: 2 additions & 2 deletions far/manager.cpp
Expand Up @@ -668,10 +668,10 @@ void Manager::ExitMainLoop(int Ask)
Global->CloseFARMenu=TRUE;
};

if (!Ask || !Global->Opt->Confirm.Exit || !Message(0, MSG(MQuit),
if (!Ask || !Global->Opt->Confirm.Exit || Message(0, MSG(MQuit),
make_vector<string>(MSG(MAskQuit)),
make_vector<string>(MSG(MYes), MSG(MNo)),
nullptr, nullptr, &FarAskQuitId))
nullptr, nullptr, &FarAskQuitId) == Message::first_button)
{
/* $ 29.12.2000 IS
+ Проверяем, сохранены ли все измененные файлы. Если нет, то не выходим
Expand Down
7 changes: 7 additions & 0 deletions far/message.hpp
Expand Up @@ -67,6 +67,13 @@ class Message: noncopyable
const wchar_t *Str6=nullptr, const wchar_t *Str7=nullptr, const wchar_t *Str8=nullptr, const wchar_t *Str9=nullptr,
const wchar_t *Str10=nullptr, const wchar_t *Str11=nullptr, const wchar_t *Str12=nullptr);

enum
{
first_button,
second_button,
third_button,
};

int GetExitCode() const {return m_ExitCode;}
void GetMessagePosition(int &X1,int &Y1,int &X2,int &Y2) const;
operator int() const { return GetExitCode(); }
Expand Down
4 changes: 2 additions & 2 deletions far/plist.cpp
Expand Up @@ -122,8 +122,8 @@ void ShowProcessList()
DWORD ProcID;
GetWindowThreadProcessId(ProcWnd,&ProcID);

if (!Message(MSG_WARNING,2,MSG(MKillProcessTitle),MSG(MAskKillProcess),
NullToEmpty(Title.get()),MSG(MKillProcessWarning),MSG(MKillProcessKill),MSG(MCancel)))
if (Message(MSG_WARNING,2,MSG(MKillProcessTitle),MSG(MAskKillProcess),
NullToEmpty(Title.get()),MSG(MKillProcessWarning),MSG(MKillProcessKill),MSG(MCancel)) == Message::first_button)
{
if (!KillProcess(ProcID))
{
Expand Down
2 changes: 1 addition & 1 deletion far/print.cpp
Expand Up @@ -262,7 +262,7 @@ void PrintFiles(FileList* SrcPanel)
else
{
if (Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MPrintTitle),MSG(MCannotPrint),
strSelName.data(),MSG(MSkip),MSG(MCancel)))
strSelName.data(),MSG(MSkip),MSG(MCancel)) != Message::first_button)
break;
}
}
Expand Down

0 comments on commit b4cb23e

Please sign in to comment.