Skip to content

Commit

Permalink
crash while calling editor after panel plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Jul 16, 2016
1 parent 3f0d952 commit 9676f1c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 45 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
drkns 16.07.2016 13:51:54 +0200 - build 4743

1. Иногда, если очень повезёт, вызов редактора после работы с панельным плагином мог приводить к падению.

drkns 09.07.2016 22:56:35 +0200 - build 4742

1. Ansi-плагины, у которых ресурсы недостаточно хороши, могли не загружаться.
Expand Down
69 changes: 26 additions & 43 deletions far/filelist.cpp
Expand Up @@ -1449,15 +1449,12 @@ int FileList::ProcessKey(const Manager::Key& Key)

if (LocalKey==KEY_CTRLF || LocalKey==KEY_RCTRLF || LocalKey==KEY_CTRLALTF || LocalKey==KEY_RCTRLRALTF || LocalKey==KEY_CTRLRALTF || LocalKey==KEY_RCTRLALTF)
{
if (m_PanelMode == panel_mode::PLUGIN_PANEL)
{
Global->CtrlObject->Plugins->GetOpenPanelInfo(m_hPlugin,&m_CachedOpenPanelInfo);
}

if (m_PanelMode != panel_mode::PLUGIN_PANEL)
CreateFullPathName(CurPtr->strName,CurPtr->strShortName,CurPtr->FileAttr, strFileName, LocalKey==KEY_CTRLALTF || LocalKey==KEY_RCTRLRALTF || LocalKey==KEY_CTRLRALTF || LocalKey==KEY_RCTRLALTF);
else
{
Global->CtrlObject->Plugins->GetOpenPanelInfo(m_hPlugin, &m_CachedOpenPanelInfo);

string strFullName = NullToEmpty(m_CachedOpenPanelInfo.CurDir);

if (Global->Opt->PanelCtrlFRule && (m_ViewSettings.Flags&PVS_FOLDERUPPERCASE))
Expand Down Expand Up @@ -1739,8 +1736,6 @@ int FileList::ProcessKey(const Manager::Key& Key)
_ALGO(CleverSysLog clv(L"Edit/View"));
_ALGO(SysLog(L"%s, FileCount=%d Key=%s",(m_PanelMode==PLUGIN_PANEL?"PluginPanel":"FilePanel"),FileCount,_FARKEY_ToName(LocalKey)));

BOOL RefreshedPanel=TRUE;

if (m_PanelMode == panel_mode::PLUGIN_PANEL)
Global->CtrlObject->Plugins->GetOpenPanelInfo(m_hPlugin,&m_CachedOpenPanelInfo);

Expand All @@ -1749,28 +1744,23 @@ int FileList::ProcessKey(const Manager::Key& Key)

if ((LocalKey==KEY_SHIFTF4 || !m_ListData.empty()) && SetCurPath())
{
int Edit=(LocalKey==KEY_F4 || LocalKey==KEY_ALTF4 || LocalKey==KEY_RALTF4 || LocalKey==KEY_SHIFTF4 || LocalKey==KEY_CTRLSHIFTF4 || LocalKey==KEY_RCTRLSHIFTF4);
BOOL Modaling=FALSE; ///
int UploadFile=TRUE;
string strPluginData;
string strFileName;
string strShortFileName;
string strHostFile=NullToEmpty(m_CachedOpenPanelInfo.HostFile);
string strInfoCurDir=NullToEmpty(m_CachedOpenPanelInfo.CurDir);
bool PluginMode = m_PanelMode == panel_mode::PLUGIN_PANEL && !Global->CtrlObject->Plugins->UseFarCommand(m_hPlugin, PLUGIN_FARGETFILE);
bool PluginMode =
m_PanelMode == panel_mode::PLUGIN_PANEL &&
!Global->CtrlObject->Plugins->UseFarCommand(m_hPlugin, PLUGIN_FARGETFILE) &&
!(m_CachedOpenPanelInfo.Flags & OPIF_REALNAMES);

if (PluginMode)
{
if (m_CachedOpenPanelInfo.Flags & OPIF_REALNAMES)
PluginMode = false;
else
strPluginData = L'<' + strHostFile + L':' + strInfoCurDir + L'>';
const string strHostFile = NullToEmpty(m_CachedOpenPanelInfo.HostFile);
const string strInfoCurDir = NullToEmpty(m_CachedOpenPanelInfo.CurDir);
strPluginData = L'<' + strHostFile + L':' + strInfoCurDir + L'>';
}

if (!PluginMode)
strPluginData.clear();

uintptr_t codepage = CP_DEFAULT;
const auto Edit = (LocalKey == KEY_F4 || LocalKey == KEY_ALTF4 || LocalKey == KEY_RALTF4 || LocalKey == KEY_SHIFTF4 || LocalKey == KEY_CTRLSHIFTF4 || LocalKey == KEY_RCTRLSHIFTF4);
string strFileName;
string strShortFileName;

if (LocalKey==KEY_SHIFTF4)
{
Expand Down Expand Up @@ -1830,16 +1820,12 @@ int FileList::ProcessKey(const Manager::Key& Key)
if (Edit)
return ProcessKey(Manager::Key(KEY_CTRLA));

CountDirSize(m_CachedOpenPanelInfo.Flags);
CountDirSize(!PluginMode);
return TRUE;
}

strFileName = CurPtr->strName;

if (!CurPtr->strShortName.empty())
strShortFileName = CurPtr->strShortName;
else
strShortFileName = CurPtr->strName;
strShortFileName = !CurPtr->strShortName.empty()? CurPtr->strShortName : CurPtr->strName;
}

string strTempDir, strTempName;
Expand Down Expand Up @@ -1889,6 +1875,9 @@ int FileList::ProcessKey(const Manager::Key& Key)
должно быт равно false, т.к. внутренний viewer сам все удалит.
*/
bool DeleteViewedFile=PluginMode && !Edit;
BOOL Modaling = FALSE;
int UploadFile = TRUE;
BOOL RefreshedPanel = TRUE;

if (!strFileName.empty())
{
Expand Down Expand Up @@ -4922,7 +4911,7 @@ bool FileList::ApplyCommand()
}


void FileList::CountDirSize(UINT64 PluginFlags)
void FileList::CountDirSize(bool IsRealNames)
{
unsigned long SelDirCount=0;
DirInfoData Data = {};
Expand Down Expand Up @@ -4979,11 +4968,8 @@ void FileList::CountDirSize(UINT64 PluginFlags)
if (i.Selected && (i.FileAttr & FILE_ATTRIBUTE_DIRECTORY))
{
SelDirCount++;
if ((m_PanelMode == panel_mode::PLUGIN_PANEL && !(PluginFlags & OPIF_REALNAMES) &&
GetPluginDirInfo(m_hPlugin, i.strName, Data.DirCount, Data.FileCount, Data.FileSize, Data.AllocationSize))
||
((m_PanelMode != panel_mode::PLUGIN_PANEL || (PluginFlags & OPIF_REALNAMES)) &&
GetDirInfo(MSG(MDirInfoViewTitle), i.strName, Data, MessageDelay, m_Filter.get(), GETDIRINFO_NOREDRAW|GETDIRINFO_SCANSYMLINKDEF)==1))
if ((!IsRealNames && GetPluginDirInfo(m_hPlugin, i.strName, Data.DirCount, Data.FileCount, Data.FileSize, Data.AllocationSize)) ||
(IsRealNames && GetDirInfo(MSG(MDirInfoViewTitle), i.strName, Data, MessageDelay, m_Filter.get(), GETDIRINFO_NOREDRAW|GETDIRINFO_SCANSYMLINKDEF)==1))
{
SelFileSize -= i.FileSize;
SelFileSize += Data.FileSize;
Expand All @@ -5000,17 +4986,14 @@ void FileList::CountDirSize(UINT64 PluginFlags)
if (!SelDirCount)
{
assert(m_CurFile < static_cast<int>(m_ListData.size()));
if ((m_PanelMode == panel_mode::PLUGIN_PANEL && !(PluginFlags & OPIF_REALNAMES) &&
GetPluginDirInfo(m_hPlugin,m_ListData[m_CurFile].strName, Data.DirCount, Data.FileCount, Data.FileSize, Data.AllocationSize))
||
((m_PanelMode!=panel_mode::PLUGIN_PANEL || (PluginFlags & OPIF_REALNAMES)) &&
GetDirInfo(MSG(MDirInfoViewTitle),
TestParentFolderName(m_ListData[m_CurFile].strName) ? L".":m_ListData[m_CurFile].strName,
auto& CurFile = m_ListData[m_CurFile];
if ((!IsRealNames && GetPluginDirInfo(m_hPlugin, CurFile.strName, Data.DirCount, Data.FileCount, Data.FileSize, Data.AllocationSize)) ||
(IsRealNames && GetDirInfo(MSG(MDirInfoViewTitle), TestParentFolderName(CurFile.strName)? L"." : CurFile.strName,
Data, getdirinfo_default_delay, m_Filter.get(), GETDIRINFO_NOREDRAW|GETDIRINFO_SCANSYMLINKDEF)==1))
{
m_ListData[m_CurFile].FileSize = Data.FileSize;
m_ListData[m_CurFile].AllocationSize = Data.AllocationSize;
m_ListData[m_CurFile].ShowFolderSize=1;
CurFile.FileSize = Data.FileSize;
CurFile.AllocationSize = Data.AllocationSize;
CurFile.ShowFolderSize = 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion far/filelist.hpp
Expand Up @@ -295,7 +295,7 @@ class FileList:public Panel
void ProcessEnter(bool EnableExec,bool SeparateWindow, bool EnableAssoc, bool RunAs, OPENFILEPLUGINTYPE Type);
// ChangeDir возвращает false, eсли не смогла выставить заданный путь
bool ChangeDir(const string& NewDir,bool ResolvePath=false,bool IsUpdated=true,const FileListItem *CurPtr=nullptr);
void CountDirSize(UINT64 PluginFlags);
void CountDirSize(bool IsRealNames);
void ReadFileNames(int KeepSelection, int UpdateEvenIfPanelInvisible, int DrawMessage);
void UpdatePlugin(int KeepSelection, int UpdateEvenIfPanelInvisible);
void MoveSelection(std::vector<FileListItem>& From, std::vector<FileListItem>& To);
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4742)m4_dnl
m4_define(BUILD,4743)m4_dnl

0 comments on commit 9676f1c

Please sign in to comment.