Commit 269d98ec authored by Claes Sjofors's avatar Claes Sjofors

Lockfile added to directory and class volumes

parent 5eb657a8
......@@ -56,6 +56,7 @@
#include "wb_vrepdbs.h"
#include "wb_vrepmem.h"
#include "wb_vrepext.h"
#include "wb_dblock.h"
#include "wb_main.h"
using namespace std;
......@@ -320,6 +321,34 @@ void Wb::wtt_open_volume( void *wttctx, wb_eType type, const char *filename, wow
else if ( file_type == wow_eFileSelType_WblClass) {
printf( "Wb opening wb_load-file %s...\n", filename);
char uname[80];
if ( wb_dblock::is_locked((char *)filename, uname)) {
char msg[120];
sprintf( msg, "Classvolume %s is locked by user %s", filename, uname);
MsgWindow::message( 'E', msg, msgw_ePop_No);
if ( ! MsgWindow::has_window())
return;
CoWow *wow = MsgWindow::get_wow();
int res = wow->CreateModalDialog( "Classvolume Locked", msg, "Cancel",
"Remove lock", 0, "$pwr_exe/wtt_padlock.png");
switch( res) {
case wow_eModalDialogReturn_Button1:
case wow_eModalDialogReturn_Deleted:
return;
case wow_eModalDialogReturn_Button2:
// Remove lock
wb_dblock::dbunlock((char *)filename);
break;
case wow_eModalDialogReturn_NYI:
case wow_eModalDialogReturn_Button3:
return;
}
}
// Load volume and import to vrepmem
wb_erep *erep = (wb_erep *)(*(wb_env *)wb->wbctx);
wb_vrepmem *mem = new wb_vrepmem(erep, 0);
......
......@@ -42,10 +42,11 @@
#include "co_time.h"
#include "cow_msgwindow.h"
#include "co_dcli.h"
#include "wb_dblock.h"
wb_vrepmem::wb_vrepmem( wb_erep *erep, pwr_tVid vid) :
wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), root_object(0), volume_object(0),
wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0), volume_object(0),
m_nextOix(0), m_source_vid(0), m_classeditor(false), m_ignore(false)
{
strcpy( m_filename, "");
......@@ -108,11 +109,14 @@ void wb_vrepmem::loadWbl( const char *filename, pwr_tStatus *sts, bool reload)
vrep->ref();
m_vid = vrep->vid();
strcpy( m_filename, filename);
name( vrep->name());
importVolume( *vrep);
vrep->unref();
wb_dblock::dblock( m_filename);
*sts = LDH__SUCCESS;
}
......@@ -342,8 +346,11 @@ mem_object *wb_vrepmem::find( const char *name)
void wb_vrepmem::unref()
{
if (--m_nRef == 0)
if (--m_nRef == 0) {
if ( strcmp( m_filename, "") != 0)
wb_dblock::dbunlock(m_filename);
delete this;
}
}
wb_vrep *wb_vrepmem::ref()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment