Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Tab Save/SaveAll fix maybe??

<< < (2/5) > >>

thomas:
I'll do the modifications quickly... need a break from the other stuff anyway...

thomas:
...and I was wrong. You do need a call to Manager::Get() because we're in an embedded class there, had not seen that, sorry ;)

Here's what it looks like now:

--- Code: ---pop->AppendSeparator();
pop->Append(idNBTabSave, _("Save"));
pop->Append(idNBTabSaveAll, _("Save all"));

EditorManager *em = Manager::Get()->GetEditorManager();
unsigned int num_modified = 0;

for (int i = 0; i < em->GetEditorsCount(); ++i)
{
    EditorBase* ed = em->GetEditor(i);
    if (ed && ed->GetModified() )
    ++num_modified;
}
pop->Enable(idNBTabSave, num_modified);
pop->Enable(idNBTabSaveAll, num_modified > 1 );
--- End code ---

It always adds the menu items for consistency instead of only showing "all" on multiple tabs.

Pecan:
thanks thomas

Nice lesson. Beautiful efficiency.

thanks
pecan

Pecan:
code from HEAD 1573 sdk/ediitormanager.cpp (12/20/2005 12:35 PM)

--- Code: --- for (int i = 0; i < em->GetEditorsCount(); ++i)
{
EditorBase* ed = em->GetEditor(i);
if (ed && ed->GetModified() )
++num_modified;
}
pop->Enable(idNBTabSave, num_modified);
pop->Enable(idNBTabSaveAll, num_modified > 1 );


--- End code ---

Put two tabs/editors up. Modify the left one.
If the left tab has been modified and the right one NOT,
then cliick on the right tab as save. It *doesn't* save. AND saveAll is disabled
because test is for "num_modified>1" and the cursor is on the
unmodified editor tab.

In my not so professional code in message 1 above, I ran across the same
problem. Thats why I tested to differentiate from "this editor" and
"other editors":


--- Code: ---     EditorBase* other = Manager::Get()->GetEditorManager()->GetEditor(i);
     if (other == ed) continue;
     if (other && other->GetModified() ) editorsModified++;

--- End code ---

thanks
pecan

thomas:
Hmm... works perfectly here.

I have added debug output just to be 100% sure, it counts correctly, too.
For me, it does save, and it displays all entries correctly, too. Tried with 1, 2, 3, 5, and 8 tabs, having 0, 1, 2, 3, or 4 modified.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version