renamed field variables to fit our guidelines. Also use sem_id instead of long

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27735 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2008-09-25 12:00:03 +00:00
parent 68fba17fe7
commit 0f85a3eb5b
2 changed files with 20 additions and 21 deletions

View File

@ -39,23 +39,23 @@ FileSelector::FileSelector(void)
: BWindow(BRect(0,0,320,160), "printtofile", B_TITLED_WINDOW, : BWindow(BRect(0,0,320,160), "printtofile", B_TITLED_WINDOW,
B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE) B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE)
{ {
m_exit_sem = create_sem(0, "FileSelector"); fExitSem = create_sem(0, "FileSelector");
m_result = B_ERROR; fResult = B_ERROR;
m_save_panel = NULL; fSavePanel = NULL;
} }
FileSelector::~FileSelector() FileSelector::~FileSelector()
{ {
delete m_save_panel; delete fSavePanel;
delete_sem(m_exit_sem); delete_sem(fExitSem);
} }
bool bool
FileSelector::QuitRequested() FileSelector::QuitRequested()
{ {
release_sem(m_exit_sem); release_sem(fExitSem);
return BWindow::QuitRequested(); return BWindow::QuitRequested();
} }
@ -67,11 +67,11 @@ FileSelector::MessageReceived(BMessage * msg)
case START_MSG: case START_MSG:
{ {
BMessenger messenger(this); BMessenger messenger(this);
m_save_panel = new BFilePanel(B_SAVE_PANEL, fSavePanel = new BFilePanel(B_SAVE_PANEL,
&messenger, NULL, 0, false); &messenger, NULL, 0, false);
m_save_panel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE); fSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
m_save_panel->Show(); fSavePanel->Show();
break; break;
} }
case B_SAVE_REQUESTED: case B_SAVE_REQUESTED:
@ -84,16 +84,16 @@ FileSelector::MessageReceived(BMessage * msg)
BDirectory bdir(&dir); BDirectory bdir(&dir);
if (msg->FindString("name", &name) == B_OK) { if (msg->FindString("name", &name) == B_OK) {
if (name != NULL) if (name != NULL)
m_result = m_entry.SetTo(&bdir, name); fResult = fEntry.SetTo(&bdir, name);
}; };
}; };
release_sem(m_exit_sem); release_sem(fExitSem);
break; break;
}; };
case B_CANCEL: case B_CANCEL:
release_sem(m_exit_sem); release_sem(fExitSem);
break; break;
default: default:
@ -110,13 +110,13 @@ FileSelector::Go(entry_ref* ref)
Hide(); Hide();
Show(); Show();
PostMessage(START_MSG); PostMessage(START_MSG);
acquire_sem(m_exit_sem); acquire_sem(fExitSem);
// cache result to avoid memory access of deleted window object // cache result to avoid memory access of deleted window object
// after Quit(). // after Quit().
status_t result = m_result; status_t result = fResult;
if (result == B_OK && ref) if (result == B_OK && ref)
result = m_entry.GetRef(ref); result = fEntry.GetRef(ref);
Lock(); Lock();
Quit(); Quit();

View File

@ -35,8 +35,7 @@
#include <InterfaceKit.h> #include <InterfaceKit.h>
#include <StorageKit.h> #include <StorageKit.h>
class FileSelector : public BWindow class FileSelector : public BWindow {
{
public: public:
// Constructors, destructors, operators... // Constructors, destructors, operators...
@ -59,10 +58,10 @@ class FileSelector : public BWindow
// From here, it's none of your business! ;-) // From here, it's none of your business! ;-)
private: private:
BEntry m_entry; BEntry fEntry;
volatile status_t m_result; volatile status_t fResult;
long m_exit_sem; sem_id fExitSem;
BFilePanel * m_save_panel; BFilePanel * fSavePanel;
}; };
#endif // FILESELECTOR_H #endif // FILESELECTOR_H