Skip to content

Commit

Permalink
fix.被垃圾回收器(Garbage Collector, GC)回收的 COM 对象时
Browse files Browse the repository at this point in the history
  • Loading branch information
indiff committed Mar 15, 2024
1 parent d072628 commit 2ecd990
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions QTTabBar/ShellBrowserEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,22 @@ internal void SetStatusText(string status) {

public void SetUsingListView(bool listview) {
if(shellBrowser != null) {
IFolderViewOptions fvo = shellBrowser as IFolderViewOptions;
if(fvo != null) {
fvo.SetFolderViewOptions(FVO.VISTALAYOUT, listview ? FVO.VISTALAYOUT : FVO.DEFAULT);
}
try // add by indiff 2023.03.15
{
// System.Runtime.InteropServices.InvalidComObjectException: COM 对象与其基础 RCW 分开后就不能再使用。
IFolderViewOptions fvo = shellBrowser as IFolderViewOptions;
if(fvo != null) {
fvo.SetFolderViewOptions(FVO.VISTALAYOUT, listview ? FVO.VISTALAYOUT : FVO.DEFAULT);
}
}
catch (COMException e)
{
QTUtility2.MakeErrorLog(e, " SetUsingListView COMException");
}
catch (InvalidComObjectException e)
{
QTUtility2.MakeErrorLog(e, " SetUsingListView InvalidComObjectException");
} // add by indiff 2023.03.15
}
}

Expand Down

0 comments on commit 2ecd990

Please sign in to comment.